[py-svn] commit/pytest: hpk42: avoid pyc file issues by parametrizing the test instead of rewriting conftest.py files

Bitbucket commits-noreply at bitbucket.org
Thu Oct 4 11:51:20 CEST 2012


1 new commit in pytest:


https://bitbucket.org/hpk42/pytest/changeset/45009f2213bc/
changeset:   45009f2213bc
user:        hpk42
date:        2012-10-04 11:51:14
summary:     avoid pyc file issues by parametrizing the test instead of rewriting conftest.py files
affected #:  1 file

diff -r df938be9a30f4c74bd4eda6c6cf09068330e88f2 -r 45009f2213bc36057470967ff709fd4a77b5257d testing/test_capture.py
--- a/testing/test_capture.py
+++ b/testing/test_capture.py
@@ -14,7 +14,8 @@
         finally:
             monkeypatch.undo()
 
-    def test_configure_per_fspath(self, testdir):
+    @pytest.mark.parametrize("mode", "no fd sys".split())
+    def test_configure_per_fspath(self, testdir, mode):
         config = testdir.parseconfig(testdir.tmpdir)
         capman = CaptureManager()
         hasfd = hasattr(os, 'dup')
@@ -23,13 +24,12 @@
         else:
             assert capman._getmethod(config, None) == "sys"
 
-        for name in ('no', 'fd', 'sys'):
-            if not hasfd and name == 'fd':
-                continue
-            sub = testdir.tmpdir.mkdir("dir" + name)
-            sub.ensure("__init__.py")
-            sub.join("conftest.py").write('option_capture = %r' % name)
-            assert capman._getmethod(config, sub.join("test_hello.py")) == name
+        if not hasfd and mode == 'fd':
+            return
+        sub = testdir.tmpdir.mkdir("dir" + mode)
+        sub.ensure("__init__.py")
+        sub.join("conftest.py").write('option_capture = %r' % mode)
+        assert capman._getmethod(config, sub.join("test_hello.py")) == mode
 
     @needsosdup
     @pytest.mark.multi(method=['no', 'fd', 'sys'])

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