Skip to content

Commit

Permalink
setuponly: remove printing out/err from capman
Browse files Browse the repository at this point in the history
This was added in pytest-dev@1a5e530b9.
The test from there provides the same output with this fix, which makes
sense, since it suspends capturing, reads the output and prints it after
resuming capturing again.  Therefore it can just leave it in the capture
buffer in the first place.

Fixes pytest-dev#5906
  • Loading branch information
blueyed committed Oct 15, 2019
1 parent a20880c commit fb44ee4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog/5906.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crash with ``KeyboardInterrupt`` during ``--setup-show``.
5 changes: 0 additions & 5 deletions src/_pytest/setuponly.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import pytest


Expand Down Expand Up @@ -51,7 +49,6 @@ def _show_fixture_action(fixturedef, msg):
capman = config.pluginmanager.getplugin("capturemanager")
if capman:
capman.suspend_global_capture()
out, err = capman.read_global_capture()

tw = config.get_terminal_writer()
tw.line()
Expand All @@ -74,8 +71,6 @@ def _show_fixture_action(fixturedef, msg):

if capman:
capman.resume_global_capture()
sys.stdout.write(out)
sys.stderr.write(err)


@pytest.hookimpl(tryfirst=True)
Expand Down
7 changes: 6 additions & 1 deletion testing/python/setup_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ def test_capturing(two):

result = testdir.runpytest("--setup-only", p)
result.stdout.fnmatch_lines(
["this should be captured", "this should also be captured"]
[
"*- Captured stdout setup -*",
"this should be captured",
"*- Captured stderr setup -*",
"this should also be captured",
]
)


Expand Down

0 comments on commit fb44ee4

Please sign in to comment.