Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency call is skipped by executing test with mark #66

Open
valeriykurdyayev opened this issue Mar 11, 2022 · 3 comments
Open

Dependency call is skipped by executing test with mark #66

valeriykurdyayev opened this issue Mar 11, 2022 · 3 comments

Comments

@valeriykurdyayev
Copy link

Test are skipped when trying to execute it with mark.

pipenv run pytest -m C999

    @pytest.mark.dependency(name="test1")
    def test_1(self):
        pass

    @pytest.mark.dependency(depends=["test1"])
    @pytest.mark.C999
    def test_2(self):
        pass

tests/cms/test_posts.py::TestArticles::test_2 SKIPPED (test_2 depends on test1) [100%]

pytest == 6.2.4
pytest-dependency == 0.5.1
@valeriykurdyayev valeriykurdyayev changed the title Dependency not working by executing with marks Dependency call are skipped by executing test with mark Mar 11, 2022
@valeriykurdyayev valeriykurdyayev changed the title Dependency call are skipped by executing test with mark Dependency call is skipped by executing test with mark Mar 12, 2022
@martinclauss
Copy link

martinclauss commented Jul 26, 2022

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

@amorin-gladia
Copy link

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 meet the same problem.
Maybe a turnaround using skipif option ?

@martinclauss
Copy link

It seems to me that this project is dead... maybe we should move on ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants