Reference

@pytest.mark.dependency(name=None, depends=[])

Mark a test to be used as a dependency for other tests or to depend on other tests.

This will cause the test results to be registered internally and thus other tests may depend on the test. The list of dependencies for the test may be set in the depends argument.

Parameters:
  • name (str) – the name of the test to be used for referencing by dependent tests. If not set, it defaults to the node ID defined by pytest, that is the name of the test function, extended by the parameters if applicable. The name must be unique in the scope, which is currently the test module.
  • depends (iterable of str) – dependencies, a list of names of tests that this test depends on. The test will be skipped unless all of the dependencies have been run successfully. The dependencies must also have been decorated by the marker.
pytest_dependency.depends(request, other)

Add dependency on other test.

Call pytest.skip() unless a successful outcome of all of the tests in other has been registered previously. This has the same effect as the depends keyword argument to the pytest.mark.dependency() marker. In contrast to the marker, this function may be called at runtime during a test.

Parameters:
  • request – the value of the request pytest fixture related to the current test.
  • other (iterable of str) – dependencies, a list of names of tests that this test depends on.

New in version 0.2.