PyTest and pytest-dependency

PyTest is foremost a unit testing framework. Unit testing frameworks generally have different needs from integration tests, and fortunately PyTest has a means to allow a developer to specify that one test needs to run and complete before another. This is done with the pytest-dependency plugin. Within the code, you will see some of the test cases annotated with dependency markers. To use this plugin, you define which tests can be dependency targets, and for any test that needs to run after it, you define the tests upon which they depend:

@pytest.mark.dependency()def test_kubernetes_components_healthy(kube_v1_client):    # iterates through the core kuberneters components to verify the cluster is reporting healthy

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.