diff --git a/_pytest/python.py b/_pytest/python.py index 77d91efae..b2ad05f8a 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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: diff --git a/testing/test_python.py b/testing/test_python.py index 21c95a75c..7c382ee3b 100644 --- a/testing/test_python.py +++ b/testing/test_python.py @@ -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)