1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/dcbe5c702399/
Changeset:   dcbe5c702399
User:        hpk42
Date:        2013-11-21 09:42:24
Summary:     addresses issue246: add a test for module/function scope that 
shows that
finalizer ordering is wrong.
Affected #:  1 file

diff -r fa4799179a30f1108d9472b5aad9139e5be6deab -r 
dcbe5c70239930fafdc762d0a427f8814c1d4799 testing/python/fixture.py
--- a/testing/python/fixture.py
+++ b/testing/python/fixture.py
@@ -1820,7 +1820,6 @@
         assert l[3] == l[4] == 2
         assert l[5] == "fin2"
 
-
     def test_parametrize_function_scoped_finalizers_called(self, testdir):
         testdir.makepyfile("""
             import pytest
@@ -1843,6 +1842,39 @@
         reprec = testdir.inline_run("-v")
         reprec.assertoutcome(passed=5)
 
+
+    @pytest.mark.issue246
+    @pytest.mark.xfail(reason="per-arg finalization does not respect order")
+    @pytest.mark.parametrize("scope", ["function", "module"])
+    def test_finalizer_order_on_parametrization(self, scope, testdir):
+        testdir.makepyfile("""
+            import pytest
+            l = []
+
+            @pytest.fixture(scope=%(scope)r, params=["1"])
+            def fix1(request):
+                return request.param
+
+            @pytest.fixture(scope=%(scope)r)
+            def fix2(request, base):
+                def cleanup_fix2():
+                    assert not l, "base should not have been finalized"
+                request.addfinalizer(cleanup_fix2)
+
+            @pytest.fixture(scope=%(scope)r)
+            def base(request, fix1):
+                def cleanup_base():
+                    l.append("fin_base")
+                request.addfinalizer(cleanup_base)
+
+            def test_baz(base, fix2):
+                pass
+        """ % {"scope": scope})
+        reprec = testdir.inline_run()
+        reprec.assertoutcome(passed=1)
+        l = reprec.getcall("pytest_runtest_call").item.module.l
+        assert l == ["test", "fin_fix2", "fin_fix3"]
+
     def test_parametrize_setup_function(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.
_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to