-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
topic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectly
Description
Version
6.2.2
Context
Running a test suite with a session fixture that does some cleaning up
Description
If the last test of the suite has a mark.xfail, the error will be marked as an additional xfailed test
Minimal example
import pytest
@pytest.fixture(autouse=True, scope='session')
def failme():
yield
raise RuntimeError('cleanup fails for some reason')
def test_01_OK():
assert 1 == 1
@pytest.mark.xfail()
def test_02_fail():
assert 0 == 1% py.test -v test.py
test.py::test_01_OK PASSED
test.py::test_02_fail XFAIL
test.py::test_02_fail XFAIL
To me, it would seem more appropriate to raise the error since the fixture is executed in the context of the session, not the test
Metadata
Metadata
Assignees
Labels
topic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectly