-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add all previous tests as dependency? Or wildcard? #19
Comments
See |
I'm not sure if I like the idea. I see at least two issues:
Some examples to illustrate the issues this: Example for the first issueThe following is perfectly valid with the current pytest-dependency: import pytest
@pytest.mark.dependency(name="whole")
@pytest.mark.xfail(reason="deliberate fail")
def test_a():
assert False
@pytest.mark.dependency(name="all")
def test_b():
pass
@pytest.mark.dependency(name="universe", depends=["all"])
def test_c():
pass
import pytest
@pytest.mark.dependency(name="whole")
@pytest.mark.xfail(reason="deliberate fail")
def test_a():
assert False
@pytest.mark.dependency(name="all")
def test_b():
pass
@pytest.mark.dependency(name="universe", depends="all")
def test_c():
pass Now, Example for the second issueAssume your proposal to be in place. Consider: import pytest
@pytest.mark.dependency(name="a")
@pytest.mark.xfail(reason="deliberate fail")
def test_a():
assert False
@pytest.mark.dependency(name="b")
def test_b():
pass
@pytest.mark.dependency(name="c", depends="all")
def test_c():
pass From reading the code, one would assume it to be equivalent with: import pytest
@pytest.mark.dependency(name="a")
@pytest.mark.xfail(reason="deliberate fail")
def test_a():
assert False
@pytest.mark.dependency(name="b")
def test_b():
pass
@pytest.mark.dependency(name="c", depends=["a", "b"])
def test_c():
pass But it is not. Assume the example to be saved as |
Issue 1 I could see being solved by adding a unique flag in the mark to avoid confusion Issue 2 I see no way around since all by definition is dynamic. Do you see any way to bring something like this into pytest-dependency? Or is the static vs dynamic definition of dependencies too great of barrier. I have other uses for pytest-dependency so it'd be nice to keep it all clean with dependency marks. The only alternative I can see is using the request fixture def test_d(request):
if request.session.testsfailed:
pytest.skip()
pass |
We have a use case where we have a very long test that we want to skip if ANY of the previous tests have failed since it will just waste time.
Would it be possible to have that added to this library?
I would envision it working like
@pytest.mark.dependenc(depends="all")
Another option would be to support regex in the depends list. So if you wanted all previous tests you could just do "test_" if you wanted all tests that started with "test_foo_" you could add that too
The text was updated successfully, but these errors were encountered: