fix issue203 - fixture functions with a scope=function should have a "self" that points to the actual instance with which the test functions run.

This commit is contained in:
holger krekel
2012-10-20 09:59:20 +02:00
parent 525b08bc5c
commit 9ed127b5da
6 changed files with 45 additions and 4 deletions

View File

@@ -2037,6 +2037,21 @@ class TestFixtureUsages:
reprec = testdir.inline_run()
reprec.assertoutcome(passed=2)
def test_request_instance_issue203(self, testdir):
testdir.makepyfile("""
import pytest
class TestClass:
@pytest.fixture
def setup1(self, request):
assert self == request.instance
self.arg1 = 1
def test_hello(self, setup1):
assert self.arg1 == 1
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)
class TestFixtureManager:
def pytest_funcarg__testdir(self, request):
testdir = request.getfuncargvalue("testdir")