1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/fa4799179a30/
Changeset:   fa4799179a30
User:        hpk42
Date:        2013-11-21 09:26:45
Summary:     move two fixture test modules into bigger testing/python/fixture.py
Affected #:  3 files

diff -r 2a1cf904d5b7854bbf4af9b30adb618a94f466c0 -r 
fa4799179a30f1108d9472b5aad9139e5be6deab testing/python/fixture.py
--- a/testing/python/fixture.py
+++ b/testing/python/fixture.py
@@ -2,7 +2,7 @@
 from _pytest import python as funcargs
 from _pytest.python import FixtureLookupError
 from _pytest.pytester import get_public_names
-
+from textwrap import dedent
 
 def test_getfuncargnames():
     def f(): pass
@@ -1738,6 +1738,60 @@
         """)
         assert "error" not in result.stdout.str()
 
+    def test_fixture_finalizer(self, testdir):
+        testdir.makeconftest("""
+            import pytest
+            import sys
+
+            @pytest.fixture
+            def browser(request):
+
+                def finalize():
+                    sys.stdout.write('Finalized')
+                request.addfinalizer(finalize)
+                return {}
+        """)
+        b = testdir.mkdir("subdir")
+        b.join("test_overriden_fixture_finalizer.py").write(dedent("""
+            import pytest
+            @pytest.fixture
+            def browser(browser):
+                browser['visited'] = True
+                return browser
+
+            def test_browser(browser):
+                assert browser['visited'] is True
+        """))
+        reprec = testdir.runpytest("-s")
+        for test in ['test_browser']:
+            reprec.stdout.fnmatch_lines('*Finalized*')
+
+    def test_class_scope_with_normal_tests(self, testdir):
+        testpath = testdir.makepyfile("""
+            import pytest
+
+            class Box:
+                value = 0
+
+            @pytest.fixture(scope='class')
+            def a(request):
+                Box.value += 1
+                return Box.value
+
+            def test_a(a):
+                assert a == 1
+
+            class Test1:
+                def test_b(self, a):
+                    assert a == 2
+
+            class Test2:
+                def test_c(self, a):
+                    assert a == 3""")
+        reprec = testdir.inline_run(testpath)
+        for test in ['test_a', 'test_b', 'test_c']:
+            assert reprec.matchreport(test).passed
+
     def test_parametrize_separated_lifecycle(self, testdir):
         testdir.makepyfile("""
             import pytest

diff -r 2a1cf904d5b7854bbf4af9b30adb618a94f466c0 -r 
fa4799179a30f1108d9472b5aad9139e5be6deab testing/test_fixture_finalizer.py
--- a/testing/test_fixture_finalizer.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""Tests for fixtures with different scoping."""
-import py.code
-
-
-def test_fixture_finalizer(testdir):
-    testdir.makeconftest("""
-    import pytest
-    import sys
-
-    @pytest.fixture
-    def browser(request):
-
-        def finalize():
-            sys.stdout.write('Finalized')
-        request.addfinalizer(finalize)
-        return {}
-    """)
-    b = testdir.mkdir("subdir")
-    b.join("test_overriden_fixture_finalizer.py").write(py.code.Source("""
-    import pytest
-    @pytest.fixture
-    def browser(browser):
-        browser['visited'] = True
-        return browser
-
-    def test_browser(browser):
-        assert browser['visited'] is True
-    """))
-    reprec = testdir.runpytest("-s")
-    for test in ['test_browser']:
-        reprec.stdout.fnmatch_lines('*Finalized*')

diff -r 2a1cf904d5b7854bbf4af9b30adb618a94f466c0 -r 
fa4799179a30f1108d9472b5aad9139e5be6deab testing/test_fixture_scope.py
--- a/testing/test_fixture_scope.py
+++ /dev/null
@@ -1,28 +0,0 @@
-"""Tests for fixtures with different scoping."""
-
-
-def test_class_scope_with_normal_tests(testdir):
-    testpath = testdir.makepyfile("""
-        import pytest
-
-        class Box:
-            value = 0
-
-        @pytest.fixture(scope='class')
-        def a(request):
-            Box.value += 1
-            return Box.value
-
-        def test_a(a):
-            assert a == 1
-
-        class Test1:
-            def test_b(self, a):
-                assert a == 2
-
-        class Test2:
-            def test_c(self, a):
-                assert a == 3""")
-    reprec = testdir.inline_run(testpath)
-    for test in ['test_a', 'test_b', 'test_c']:
-        assert reprec.matchreport(test).passed

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