make sure setups are called ahead of the funcarg factories of the test function

This commit is contained in:
holger krekel 2012-09-24 10:36:22 +02:00
parent 754fab9b55
commit 7768972ec5
2 changed files with 18 additions and 1 deletions

View File

@ -895,9 +895,9 @@ class Function(FunctionMixin, pytest.Item):
def setup(self):
super(Function, self).setup()
fillfuncargs(self)
if hasattr(self, "_request"):
self._request._callsetup()
fillfuncargs(self)
def __eq__(self, other):
try:

View File

@ -2633,3 +2633,20 @@ def test_request_can_be_overridden(testdir):
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)
def test_setup_funcarg_order(testdir):
testdir.makepyfile("""
import pytest
l = []
@pytest.setup()
def fix1():
l.append(1)
@pytest.factory()
def arg1():
l.append(2)
def test_hello(arg1):
assert l == [1,2]
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)