Open valeriykurdyayev opened 2 years ago
I'm not sure whether it's the same problem but I have the following behavior:
import pytest
@pytest.mark.dependency()
@pytest.mark.parametrize("message", ["hello", "world"])
def test_a(message):
print(message)
assert True
@pytest.mark.dependency(depends=["test_a"])
def test_b():
assert True
My output when I run
pytest -rsx tests/test_dep.py
is
========================================================== test session starts ===========================================================
platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/user/pytest_dep_test
plugins: dependency-0.5.1
collected 3 items
tests/test_dep.py ..s [100%]
======================================================== short test summary info =========================================================
SKIPPED [1] ../../../../../../tmp/pytest_dep_venv/lib64/python3.10/site-packages/pytest_dependency.py:103: test_b depends on test_a
====================================================== 2 passed, 1 skipped in 0.01s ======================================================
test_a
will never fail but still test_b
is skipped. In the documentation it says:
In the same way as the pytest.mark.skip() and pytest.mark.xfail() markers, the pytest.mark.dependency() marker may be applied to individual test instances in the case of parametrized tests.
The may be applied sounds optional to me :)
However, when I remove the @pytest.mark.parametrize
like this:
import pytest
@pytest.mark.dependency()
# @pytest.mark.parametrize("message", ["hello", "world"])
# def test_a(message):
def test_a():
assert True
@pytest.mark.dependency(depends=["test_a"])
def test_b():
assert True
it works:
========================================================== test session starts ===========================================================
platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0
rootdir: [...]
plugins: dependency-0.5.1
collected 2 items
tests/test_dep.py .. [100%]
=========================================================== 2 passed in 0.00s ============================================================
Also if test_a
will assert False
the correct behavior is acheived (Fs
)!
Python version: 3.10.5 pytest version: 7.1.2 pytest-dependency version: 0.5.1
Thanks for your help!
Best regards
I'm not sure whether it's the same problem but I have the following behavior:
import pytest @pytest.mark.dependency() @pytest.mark.parametrize("message", ["hello", "world"]) def test_a(message): print(message) assert True @pytest.mark.dependency(depends=["test_a"]) def test_b(): assert True
My output when I run
pytest -rsx tests/test_dep.py
is
========================================================== test session starts =========================================================== platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/user/pytest_dep_test plugins: dependency-0.5.1 collected 3 items tests/test_dep.py ..s [100%] ======================================================== short test summary info ========================================================= SKIPPED [1] ../../../../../../tmp/pytest_dep_venv/lib64/python3.10/site-packages/pytest_dependency.py:103: test_b depends on test_a ====================================================== 2 passed, 1 skipped in 0.01s ======================================================
test_a
will never fail but stilltest_b
is skipped. In the documentation it says:In the same way as the pytest.mark.skip() and pytest.mark.xfail() markers, the pytest.mark.dependency() marker may be applied to individual test instances in the case of parametrized tests.
The may be applied sounds optional to me :)
However, when I remove the
@pytest.mark.parametrize
like this:import pytest @pytest.mark.dependency() # @pytest.mark.parametrize("message", ["hello", "world"]) # def test_a(message): def test_a(): assert True @pytest.mark.dependency(depends=["test_a"]) def test_b(): assert True
it works:
========================================================== test session starts =========================================================== platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0 rootdir: [...] plugins: dependency-0.5.1 collected 2 items tests/test_dep.py .. [100%] =========================================================== 2 passed in 0.00s ============================================================
Also if
test_a
willassert False
the correct behavior is acheived (Fs
)!Python version: 3.10.5 pytest version: 7.1.2 pytest-dependency version: 0.5.1
Thanks for your help!
Best regards
I meet the same problem. Maybe a turnaround using skipif option ?
It seems to me that this project is dead... maybe we should move on ;)
Test are skipped when trying to execute it with mark.
pipenv run pytest -m C999
tests/cms/test_posts.py::TestArticles::test_2 SKIPPED (test_2 depends on test1) [100%]