[py-svn] commit/pytest: hpk42: make sure setups are called ahead of the funcarg factories of the test function

Bitbucket commits-noreply at bitbucket.org
Mon Sep 24 10:36:32 CEST 2012


1 new commit in pytest:


https://bitbucket.org/hpk42/pytest/changeset/07e5a98aceca/
changeset:   07e5a98aceca
user:        hpk42
date:        2012-09-24 10:36:22
summary:     make sure setups are called ahead of the funcarg factories of the test function
affected #:  2 files

diff -r d9eff229919e8ccf3d32cd66d4828eaeb74e332c -r 07e5a98aceca50ad07e99b226baf6dd9d84ce380 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -895,9 +895,9 @@
 
     def setup(self):
         super(Function, self).setup()
-        fillfuncargs(self)
         if hasattr(self, "_request"):
             self._request._callsetup()
+        fillfuncargs(self)
 
     def __eq__(self, other):
         try:


diff -r d9eff229919e8ccf3d32cd66d4828eaeb74e332c -r 07e5a98aceca50ad07e99b226baf6dd9d84ce380 testing/test_python.py
--- a/testing/test_python.py
+++ b/testing/test_python.py
@@ -2633,3 +2633,20 @@
     """)
     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)

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the pytest-commit mailing list