Automatically run dependencies for pytest

We have pytests with dependencies.  When I run an individual test, it returns an error that the dependency was not run.  Is there a configuration option to run the depedency test instead of returning an error?

e.g.

@pytest.mark.dependency(depends=["test_setup"])
def test_A():
   …

When I run just test_A, I get the error message test_setup has not been run.

Instead, I would prefer pycharm to run test_setup

I know I can change the run configuration of test_A, but I would prefer this to be a global setting rather than have to change each test.

Thanks.

 

2

That is a really good question.  I have the same problem.

0
Hello there,
Tried to reproduce the error using the dependency example from pytest, but it seems to work as expected if I run single tests from the batch. 
Could you please share a simplified version of your project so we can test that?
0

I have the same issue and find it very inconvenient. You can easily reproduce it by just running only test_b

import pytest

@pytest.mark.dependency(name="a")
def test_a():
    pass

@pytest.mark.dependency(depends=["a"])
def test_b():
    pass

Result: [pytest_dependency:100]: skip test_b because it depends on a

PyCharm 2024.3.1.1 Build #PC-243.22562.220, built on December 18, 2024

0

请先登录再写评论。