Git Product home page Git Product logo

Comments (3)

martinclauss avatar martinclauss commented on July 18, 2024

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

from pytest-dependency.

amorin-gladia avatar amorin-gladia commented on July 18, 2024

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 ?

from pytest-dependency.

martinclauss avatar martinclauss commented on July 18, 2024

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

from pytest-dependency.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.