[Pytest-commit] commit/pytest: hpk42: fix issue547 2.6 regression: capsys/capfd now work again when output capturing ("-s") is disabled.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jul 28 13:18:34 CEST 2014


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/16fab48aa572/
Changeset:   16fab48aa572
User:        hpk42
Date:        2014-07-28 13:17:37
Summary:     fix issue547 2.6 regression: capsys/capfd now work again when output capturing ("-s") is disabled.
Affected #:  3 files

diff -r 40c9e9432ff68474553a702b718262ee8e2fa1ac -r 16fab48aa572f966878eecc12d7344ec1102d02e CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 NEXT
 -----------------------------------
 
+- fix issue547 capsys/capfd also work when output capturing ("-s") is disabled.
+
 - address issue170: allow pytest.mark.xfail(...) to specify expected exceptions via
   an optional "raises=EXC" argument where EXC can be a single exception
   or a tuple of exception classes.  Thanks David Mohr for the complete

diff -r 40c9e9432ff68474553a702b718262ee8e2fa1ac -r 16fab48aa572f966878eecc12d7344ec1102d02e _pytest/capture.py
--- a/_pytest/capture.py
+++ b/_pytest/capture.py
@@ -20,7 +20,7 @@
 def pytest_addoption(parser):
     group = parser.getgroup("general")
     group._addoption(
-        '--capture', action="store", 
+        '--capture', action="store",
         default="fd" if hasattr(os, "dup") else "sys",
         metavar="method", choices=['fd', 'sys', 'no'],
         help="per-test capturing method: one of fd|sys|no.")
@@ -33,8 +33,6 @@
 def pytest_load_initial_conftests(early_config, parser, args, __multicall__):
     ns = early_config.known_args_namespace
     pluginmanager = early_config.pluginmanager
-    if ns.capture == "no":
-        return
     capman = CaptureManager(ns.capture)
     pluginmanager.register(capman, "capturemanager")
 

diff -r 40c9e9432ff68474553a702b718262ee8e2fa1ac -r 16fab48aa572f966878eecc12d7344ec1102d02e testing/test_capture.py
--- a/testing/test_capture.py
+++ b/testing/test_capture.py
@@ -392,13 +392,14 @@
 
 
 class TestCaptureFixture:
-    def test_std_functional(self, testdir):
+    @pytest.mark.parametrize("opt", [[], ["-s"]])
+    def test_std_functional(self, testdir, opt):
         reprec = testdir.inline_runsource("""
             def test_hello(capsys):
                 print (42)
                 out, err = capsys.readouterr()
                 assert out.startswith("42")
-        """)
+        """, *opt)
         reprec.assertoutcome(passed=1)
 
     def test_capsyscapfd(self, testdir):

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