Cache exception raised in fixtures according to their scope
Without this if a session scoped fixture fails it's setup it will be re-tried each time it is requested. Especially in case of skip or failure exceptions this can be undesirable, but caching makes sense for all exceptions.
This commit is contained in:
@@ -1430,6 +1430,25 @@ class TestFixtureMarker:
|
||||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=3)
|
||||
|
||||
def test_scope_session_exc(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
l = []
|
||||
@pytest.fixture(scope="session")
|
||||
def fix():
|
||||
l.append(1)
|
||||
pytest.skip('skipping')
|
||||
|
||||
def test_1(fix):
|
||||
pass
|
||||
def test_2(fix):
|
||||
pass
|
||||
def test_last():
|
||||
assert l == [1]
|
||||
""")
|
||||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(skipped=2, passed=1)
|
||||
|
||||
def test_scope_module_uses_session(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
||||
Reference in New Issue
Block a user