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

Rerunning skipped cases when the parent test fails #74

Open
sramasub opened this issue Sep 24, 2023 · 1 comment
Open

Rerunning skipped cases when the parent test fails #74

sramasub opened this issue Sep 24, 2023 · 1 comment

Comments

@sramasub
Copy link

I have the following code:

_import pytest, pytest_dependency, pytest_order

@pytest.mark.order(1)
@pytest.mark.dependency(name="1")
def test_1():
assert 1==1

@pytest.mark.order(2)
@pytest.mark.dependency(name="2", depends="1")
def test_2():
assert 1==1

@pytest.mark.order(3)
@pytest.mark.dependency(name="3", depends="2")
def test_3():
assert 1==1

@pytest.mark.order(4)
@pytest.mark.dependency(name="4", depends="3")
def test_4():
assert 1==1_

All the above runs in the defined order when they pass.

Now lets's say test_2() fails:

_============================= test session starts =============================
collecting ... collected 4 items

randomTests.py::test_1 PASSED [ 25%]
randomTests.py::test_2 FAILED [ 50%]
randomTests.py:7 (test_2)
1 != 2

Expected :2
Actual :1

@pytest.mark.order(2)
@pytest.mark.dependency(name="2", depends="1")
def test_2():

  assert 1==2

E assert 1 == 2

randomTests.py:11: AssertionError

randomTests.py::test_3 SKIPPED (test_3 depends on 2) [ 75%]
Skipped: test_3 depends on 2

randomTests.py::test_4 SKIPPED (test_4 depends on 3) [100%]
Skipped: test_4 depends on 3

=================== 1 failed, 1 passed, 2 skipped in 0.56s ====================_

Tests 3 and 4 are skipped because test_3 depends on test_2 and test_4 depends on test_3. Now i rectify test_2 to fix the problem and rerun the failed case using the 'last failed' parameter.

_============================= test session starts =============================
collecting ... collected 4 items / 3 deselected / 1 selected
run-last-failure: rerun previous 1 failure

randomTests.py::test_2 SKIPPED (test_2 depends on 1) [100%]
Skipped: test_2 depends on 1

====================== 1 skipped, 3 deselected in 0.03s =======================_

Only test 2 runs. I want test3 and test4 to be also picked because they were unable to run last time. Is there any way to achieve this?

@ydirson
Copy link

ydirson commented Jun 12, 2024

This would be the scope of something like #56, which is likely not to land in pytest-dependency itself, but could be implemented as a separate plugin. I've started to think about this (though it is quite tricky indeed, so other tasks have taken higher priority right now)

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

2 participants