Questions tagged [pytest-dependency]

Use this tag if you use the pytest-dependency plugin, which allows to mark tests as dependent on each other.

pytest-dependency allows to mark tests as dependent on other tests and ensures that the test execution order respects these dependencies. A test will also be skipped if a test it depends on had not passed.

Reference:

19 questions
17
votes
1 answer

Dependencies between files with pytest-dependency?

I'm working on a functional test suite using pytest with pytest-dependency. I 99% love these tools, but I can't figure out how to have a test in one file depend on a test in another file. Ideally, I'd like to have zero changes required to the…
Claire Nielsen
  • 1,881
  • 1
  • 14
  • 31
5
votes
1 answer

Pytest parametrized dependency

I have a function and a test def foo(a): return bar(a) @pytest.mark.parametrize( 'number', [1,2,3] ) @pytest.mark.dependency def test_foo(number): assert foo(number) > SOME_CONST # Simplistic example, real case is more nuanced I'm…
F. Elliot
  • 228
  • 2
  • 10
3
votes
1 answer

How to impose order on fixtures in pytest?

I am trying to use pytest-dependency to make fixtures happen in order, regardless of how they are named, and regardless of the order in which they appear in a test's argument list. The reason I need this, is to create fixtures that require…
Gulzar
  • 23,452
  • 27
  • 113
  • 201
3
votes
1 answer

run dependant tests with pytest

With pytest, I'm setting dependencies using the library pytest-dependency. I also add markers to those tests. Here is an ECM : # test_test.py import pytest @pytest.mark.dependency() def test_a(): assert…
Thomas
  • 263
  • 3
  • 14
2
votes
1 answer

pytest-dependency is not working in my test

There are 2 files, the code in the first one is: import pytest class TestXdist2(): @pytest.mark.dependency(name="aa") def test_t1(self): print("\ntest_1") assert True the code in the second file is: import pytest import…
Yaogang Xu
  • 21
  • 4
1
vote
0 answers

How to get return / yield value of pytest dependency

I am using pytest-dependency to create dependency on tests. I want the dependent test to get return value from another test. Example: @pytest.mark.dependency() def test_owner_create_book(app): response = app.post(...) return…
PaxPrz
  • 1,778
  • 1
  • 13
  • 29
1
vote
1 answer

pytest not acknowledging PASSED dependency in base class results in SKIPPED tests in derived class

I have this little project where I use pytest and pytest-dependency with tox to develop integration tests on some code. Until now I used one base class (BTestClass) with some common tests in the root directory and the specific tests for each code…
DaLynX
  • 328
  • 1
  • 11
1
vote
1 answer

pytest-dependency skips dependent test

I want to run some tests that depend on the sucess of other tests using pytest and pytest-dependency. I have this directory structure: root/ tests/ specs/ a_test.py b_test.py The content of a_test.py: import…
soufiane yakoubi
  • 861
  • 11
  • 31
1
vote
0 answers

In pytest-dependency, is there a way to execute tests only if all of multiple parametrized test cases pass?

I have a bunch of tests running in Pytest that depend on a series of tests running in a class. I'm using pytest-dependency to run some other tests in another module, but only if all the tests in this dependency class pass. This is the set of tests…
1
vote
3 answers

How to make test that depends on parametrized test. (Pytest)

Why second test is skipped? I want second test to depend on three tests which are parametrized as test_first. How to make it happen? import pytest from pytest_dependency import depends param = [10,20,30] @pytest.mark.parametrize("param", param) def…
ged
  • 687
  • 7
  • 19
1
vote
0 answers

Pytest: How to set test in one file to be skipped if test from another file fails

I need to organize my test cases because I have a large test suite. I can't see to get a test in one Python class to be skipped if a test it depends on in another Python class fails. Here is my basic setup: class TestWorkflow1: @staticmethod …
Selena
  • 2,208
  • 8
  • 29
  • 49
1
vote
1 answer

How can I tell pytest-dependency to temporarily ignore test dependencies?

I've got a functional test suite using pytest-dependency to skip tests when other tests they depend on fail. That way, for example, if the login page is broken, I get one test failure saying "The login page is broken" instead of a slew of test…
Claire Nielsen
  • 1,881
  • 1
  • 14
  • 31
0
votes
1 answer

pytest dependency with unused marks

I have the following code: @pytest.mark.dependency @pytest.mark.test_a def test_a(): @pytest.mark.dependency(depends=["test_a"], reason="Skipped since test_a failed") @pytest.mark.test_b def test_b(): I have a python test…
Avi Elgal
  • 149
  • 1
  • 3
  • 9
0
votes
0 answers

Why some testcases fail in Pytest even after their dependencies have run successfully before them?

I have been trying to run some testcases which are dependent on other testcases. So, I made sure to use the pytest.mark.dependency marker and also made sure that the dependencies (the ones upon which the cases are dependent) execute before the…
0
votes
1 answer

Skipping specific parametrized pytests based on failure for specific parameters

I have some parametrized tests def test1(): #do test1 def test2(): #do test2 def test3(): #do test3 Each test is parametrized by @pytest.mark.parametrize(x) I would like to run these tests against test_data=[1,2,3,4] I have tried using…
00__00__00
  • 4,834
  • 9
  • 41
  • 89
1
2