1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/changeset/3d4ebcbd4079/
changeset:   3d4ebcbd4079
user:        hpk42
date:        2012-10-22 12:16:54
summary:     fix teardown-ordering for parametrized setups/teardowns
affected #:  5 files

diff -r f8223edf907244076e98eeae576f896489354d55 -r 
3d4ebcbd4079e310abdc4ab53941527ebb6e67fd CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,8 @@
 - fix issue205 - conftests in subdirs customizing
   pytest_pycollect_makemodule now work properly
 
+- fix teardown-ordering for parametrized setups
+
 - fix exception message check of test_nose.py to pass on python33 as well
 
 - fix issue206 - fix test_assertrewrite.py to work when a global


diff -r f8223edf907244076e98eeae576f896489354d55 -r 
3d4ebcbd4079e310abdc4ab53941527ebb6e67fd _pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
 #
-__version__ = '2.3.2.dev5'
+__version__ = '2.3.2.dev6'


diff -r f8223edf907244076e98eeae576f896489354d55 -r 
3d4ebcbd4079e310abdc4ab53941527ebb6e67fd _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -1531,7 +1531,7 @@
             item.session._setupstate._callfinalizers((name, param))
             l = self._arg2finish.get(name)
             if l is not None:
-                for fin in l:
+                for fin in reversed(l):
                     fin()
 
     def parsefactories(self, node_or_obj, nodeid=None, unittest=False):


diff -r f8223edf907244076e98eeae576f896489354d55 -r 
3d4ebcbd4079e310abdc4ab53941527ebb6e67fd setup.py
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@
         name='pytest',
         description='py.test: simple powerful testing with Python',
         long_description = long_description,
-        version='2.3.2.dev5',
+        version='2.3.2.dev6',
         url='http://pytest.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],


diff -r f8223edf907244076e98eeae576f896489354d55 -r 
3d4ebcbd4079e310abdc4ab53941527ebb6e67fd testing/test_python.py
--- a/testing/test_python.py
+++ b/testing/test_python.py
@@ -2763,6 +2763,43 @@
         reprec = testdir.inline_run("-v")
         reprec.assertoutcome(passed=12+1)
 
+    def test_parametrized_fixture_teardown_order(self, testdir):
+        testdir.makepyfile("""
+            import pytest
+            @pytest.fixture(params=[1,2], scope="class")
+            def param1(request):
+                return request.param
+
+            l = []
+
+            class TestClass:
+                @classmethod
+                @pytest.fixture(scope="class", autouse=True)
+                def setup1(self, request, param1):
+                    l.append(1)
+                    request.addfinalizer(self.teardown1)
+                @classmethod
+                def teardown1(self):
+                    assert l.pop() == 1
+                @pytest.fixture(scope="class", autouse=True)
+                def setup2(self, request, param1):
+                    l.append(2)
+                    request.addfinalizer(self.teardown2)
+                @classmethod
+                def teardown2(self):
+                    assert l.pop() == 2
+                def test(self):
+                    pass
+
+            def test_finish():
+                assert not l
+        """)
+        result = testdir.runpytest("-v")
+        result.stdout.fnmatch_lines("""
+            *3 passed*
+        """)
+        assert "error" not in result.stdout.str()
+
     def test_parametrize_separated_lifecycle(self, testdir):
         testdir.makepyfile("""
             import pytest

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.
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to