Comments (5)
Trying to boil down your setting to a minimal example, I believe you are trying to do something like this:
import pytest
@pytest.mark.dependency()
@pytest.mark.xfail(reason="deliberate fail")
def test_a():
assert False
@pytest.mark.dependency()
def test_b():
pass
@pytest.mark.dependency(depends=["test_a"])
@pytest.mark.dependency(depends=["test_b"])
def test_c(request):
pass
Indeed, if you try this, test_c
will not be skipped, even though test_a
fails. In fact, using multiple pytest.mark.dependency
markers for a single test simply does not work. The dependencies in the markers will not be combined, but the dependencies from the second marker will override those from the first. That is why the dependency on test_a
will simply be ignored. This seem to be consistent with what you describe in your setting. The simple example must be rewritten as follows to work:
import pytest
@pytest.mark.dependency()
@pytest.mark.xfail(reason="deliberate fail")
def test_a():
assert False
@pytest.mark.dependency()
def test_b():
pass
@pytest.mark.dependency(depends=["test_a", "test_b"])
def test_c(request):
pass
In your setting, you might want to try something like the following:
@pytest.mark.dependency(
depends=instances(
"tests/test_xyz.py::TestThis::test_that",
params_this,
) + instances(
"tests/test_xyz.py::TestThis::test_this_as_well",
params_that,
),
scope="session",
)
class TestEverything:
"""Class to test everything."""
from pytest-dependency.
Hey @RKrahl thanks for your response. Appreciate the work you have done on this package. I did try the exact setting you suggested, but I find any combination of it skips all the tests in the dependency marker.
I do not have the @pytest.mark.xfail
marker on the test class that needs to pass, but I don't think that should matter.
tests/test_steady_state.py::TestThis::test_that[a] PASSED
tests/test_steady_state.py::TestThis::test_that[b] PASSED
tests/test_steady_state.py::TestThis::test_that[c] PASSED
tests/test_steady_state.py::TestThis::test_that[d] PASSED
tests/test_steady_state.py::TestThis::test_that[e] PASSED
tests/test_steady_state.py::TestThis::test_this_as_well[a] PASSED
tests/test_steady_state.py::TestThis::test_this_as_well[b] PASSED
tests/test_steady_state.py::TestThis::test_this_as_well[c] PASSED
tests/test_steady_state.py::TestThis::test_this_as_well[d] PASSED
tests/test_steady_state.py::TestThis::test_this_as_well[e] PASSED
tests/test_all.py::TestEverything::test_pre[test_content0-xyz] SKIPPED
tests/test_all.py::TestEverything::test_body[test_content0-xyz] SKIPPED
tests/test_all.py::TestEverything::test_post[test_content0-xyz] SKIPPED
tests/test_all.py::TestEverything::test_pre[test_content1-xyz] SKIPPED
tests/test_all.py::TestEverything::test_body[test_content1-xyz] SKIPPED
tests/test_all.py::TestEverything::test_post[test_content1-xyz] SKIPPED
Is this something you're able to replicate? I have the same "session" scope in my dependency settings as well.
from pytest-dependency.
Also, it would be great to be able to have pytest-dependency run based on a class dependency rather than a method, for example
@pytest.mark.dependency(
depends=instances(
"tests/test_xyz.py::TestThis",
params_this,
scope="session",
)
class TestEverything:
"""Class to test everything."""
from pytest-dependency.
@anishradvani, I'm sorry, I'm not able to debug your code. First of all, I can't do this because you posted only fragments of it by now, so I don't have the full picture. But even if you had posted your full code, I can't do this simply because I don't have the time to do your home work.
If you believe to see some behavior that hints on a bug in pytest-dependency, I have to ask you to create a minimal example (in the same manner as I did above) of code that reproduces the alleged bug.
Regarding your last comment: actually this works, see #39.
from pytest-dependency.
This issue originally was about that multiple dependency markers for a single test does not work. Actually this was never supposed to work. I'll therefore close as invalid.
from pytest-dependency.
Related Issues (20)
- Test suite incompatibility with pytest 6.2 HOT 2
- Tests skipped on linux(3.6.13)(with no test failed) but executing on windows(3.6.10) HOT 3
- Dependency between two tests HOT 1
- session scope not working HOT 1
- Depends on all test methods in class HOT 1
- Conditional dependency on 2 tests HOT 2
- 0.5.1: pytest is failing HOT 4
- Is ordering on fixtures supported?
- only test_b is passed when install pytest-xdist with n>2.
- Not skipping a test when parent test skips or xfails
- The test was skipped,although the dependency test is success. HOT 5
- Dependency call is skipped by executing test with mark HOT 3
- pytest dependency not skipping the dependent tests when failed HOT 3
- when the dependency case use @pytest.mark.parametrize, depened cases was skipped,although the dependency test is success HOT 1
- is @pytest.mark.dependency() can be used for class level? like API test class depends on BVT test class...
- pyproject.toml missing
- Inheriting from test class with dependencies doesn't work correctly HOT 1
- Is pytest-dependency suppose to tell me why a test was skipped? I see nothing in the output explaining why. HOT 1
- Rerunning skipped cases when the parent test fails
- 0.6.0: pep517 based build fails with `Invalid version: 'UNKNOWN'` error message HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-dependency.