I see the tests are not rerunning if there is any exception at the fixture level and tests fail because of it. Could you please help. Thanks in advance. Following is my test example code:
import pytest
@pytest.fixture()
def configgen(request):
i = 1
print("Testing for a fixture level exception")
if i:
raise Exception("In Fixture")
else:
return "HIIII"
Testing for a fixture level exception
ERROR
Test: test_1 Finished...
test_testing.py::test_2 0
Test: test_2 Started...
Test: test_2 Finished...
1
Test: test_2 Started...
FAILED
Test: test_2 Finished...
test_testing.py::test_3 0
Test: test_3 Started...
Testing for a fixture level exception
ERROR
Test: test_3 Finished...
======================================================================== ERRORS =========================================================================
_ ERROR at setup of test_1 __
test_testing.py:8: in configgen
raise Exception("In Fixture")
E Exception: In Fixture
_ ERROR at setup of test_3 __
test_testing.py:8: in configgen
raise Exception("In Fixture")
E Exception: In Fixture
======================================================================= FAILURES ========================================================================
____ test2 ____
test_testing.py:16: in test_2
assert False
E assert False
===Flaky Test Report===
test_2 failed (1 runs remaining out of 2).
<class 'AssertionError'>
assert False
[]
test_2 failed; it passed 0 out of the required 1 times.
<class 'AssertionError'>
assert False
[]
===End Flaky Test Report===
============================================================== 1 failed, 2 errors in 0.07s ==============================================================
Here in the above case, I see only test_2 is rerunning with flaky as its not connected to any fixture and test_1 and test_3 are not rerunning as there was an exception in the fixture level.
I see the tests are not rerunning if there is any exception at the fixture level and tests fail because of it. Could you please help. Thanks in advance. Following is my test example code:
import pytest
@pytest.fixture() def configgen(request): i = 1 print("Testing for a fixture level exception") if i: raise Exception("In Fixture") else: return "HIIII"
def test_1(request, configgen): print(configgen)
def test_2(request): assert False
def test_3(request, configgen): print(configgen)
Result: py.test ./test_testing.py -vv -s --force-flaky
test_testing.py::test_1 0
Test: test_1 Started...
Testing for a fixture level exception ERROR Test: test_1 Finished...
test_testing.py::test_2 0
Test: test_2 Started...
Test: test_2 Finished...
1
Test: test_2 Started...
FAILED Test: test_2 Finished...
test_testing.py::test_3 0
Test: test_3 Started...
Testing for a fixture level exception ERROR Test: test_3 Finished...
======================================================================== ERRORS ========================================================================= _ ERROR at setup of test_1 __ test_testing.py:8: in configgen raise Exception("In Fixture") E Exception: In Fixture _ ERROR at setup of test_3 __ test_testing.py:8: in configgen raise Exception("In Fixture") E Exception: In Fixture ======================================================================= FAILURES ======================================================================== ____ test2 ____ test_testing.py:16: in test_2 assert False E assert False ===Flaky Test Report===
test_2 failed (1 runs remaining out of 2). <class 'AssertionError'> assert False []
test_2 failed; it passed 0 out of the required 1 times.
<class 'AssertionError'>
assert False
[]
===End Flaky Test Report=== ============================================================== 1 failed, 2 errors in 0.07s ==============================================================
Here in the above case, I see only test_2 is rerunning with flaky as its not connected to any fixture and test_1 and test_3 are not rerunning as there was an exception in the fixture level.
Flaky version: 3.6.1