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

pytest flaky interaction causing fixture exceptions to be ignored #120

Closed
timyhou opened this issue Feb 9, 2017 · 1 comment
Closed

Comments

@timyhou
Copy link

timyhou commented Feb 9, 2017

Somewhat related to this issue which was supposedly resolved in Flaky 3.1.1

In the example below, something in flaky is causing the exception that is thrown inside the fixture not to be reported anymore.

import pytest
import flaky

@pytest.fixture
def failing_fixture():
    raise Exception("Woops")

@flaky.flaky()
@pytest.mark.usefixtures('failing_fixture')
class TestCases:
    def test_fixture_fail(self):
        pass

    def test_always_pass(self):
        assert True

    def test_always_fail(self):
        assert False

The test results show that 3 tests were gathered but none were executed (which is true) but leaves no trace to the exception in the fixture.


platform linux -- Python 3.5.1, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /home/thou/mine/python_scribbles, inifile: 
plugins: flaky-3.3.0
collected 3 items 

my_pytest.py 
===Flaky Test Report===


===End Flaky Test Report===

 no tests ran in 0.02 seconds

If we remove the flaky decorator from the test class, the error is reported normally.

tomasji pushed a commit to tomasji/flaky that referenced this issue Feb 21, 2017
When a pytest test case fails during setup
(either in a fixture or setup_method/setup_class), flaky
should handle that kind of situation.
@OlehKuzovkov
Copy link

Hi guys!
I found really helpful this plugging, however because of this issue I cannot use it. In case of failure in the fixture, test case marked as passed :(

@pytest.fixture
def test_fixture():
    raise Exception("Oops")

@pytest.mark.usefixtures("test_fixture")
@flaky(max_runs=2)
class TestFlaky:

    def test(self, test_fixture):
        print("test executed")
        assert False, 'Test 1 failed'

    def test_2(self):
        print("test 2 executed")
        assert False, 'Test 2 failed'

Could you please let us know when it will be fixed?

nmalaguti added a commit to nmalaguti/flaky that referenced this issue May 24, 2017
nmalaguti added a commit to nmalaguti/flaky that referenced this issue May 24, 2017
nmalaguti added a commit to nmalaguti/flaky that referenced this issue Jun 12, 2017
If there is a failure on setup, fail the test case no matter what flaky
settings are configured.

We do not retry on setup failures because xdist has issues when
attempting to retry setup failures.

Fixes box#120
nmalaguti added a commit to nmalaguti/flaky that referenced this issue Jun 15, 2017
If there is a failure on setup, fail the test case no matter what flaky
settings are configured.

We do not retry on setup failures because xdist has issues when
attempting to retry setup failures.

Fixes box#120, box#117, box#124, box#114
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