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

tests are not rerunning if the exception happens in fixture level #172

Open
lalithach opened this issue Dec 14, 2020 · 1 comment
Open

Comments

@lalithach
Copy link

lalithach commented Dec 14, 2020

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 ========================================================================
________________________________________________________________________ test_2 _________________________________________________________________________
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

@lalithach
Copy link
Author

Hi, could someone please respond to this issue. Thanks.

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

1 participant