make yielded tests participate in the autouse protocol

This commit is contained in:
holger krekel
2012-11-19 22:17:59 +01:00
parent d66ff7e63e
commit f263f54889
3 changed files with 29 additions and 8 deletions

View File

@@ -968,6 +968,24 @@ class TestAutouseManagement:
reprec = testdir.inline_run("-s")
reprec.assertoutcome(passed=1)
def test_autouse_honored_for_yield(self, testdir):
testdir.makepyfile("""
import pytest
@pytest.fixture(autouse=True)
def tst():
global x
x = 3
def test_gen():
def f(hello):
assert x == abs(hello)
yield f, 3
yield f, -3
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=2)
def test_funcarg_and_setup(self, testdir):
testdir.makepyfile("""
import pytest