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:
Floris Bruynooghe
2014-04-15 22:22:41 -04:00
parent 65a145e2a7
commit c46e2cbbc7
3 changed files with 35 additions and 18 deletions

View File

@@ -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