File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 22from __future__ import absolute_import , division , print_function
33
44import traceback
5+ import sys
6+ import platform
57
68import pytest
79from _pytest ._code .code import ExceptionInfo , ReprFileLocation , TerminalRepr
@@ -103,8 +105,21 @@ def setup(self):
103105
104106 def runtest (self ):
105107 _check_all_skipped (self .dtest )
108+ self ._disable_output_capturing_for_darwin ()
106109 self .runner .run (self .dtest )
107110
111+ def _disable_output_capturing_for_darwin (self ):
112+ """
113+ Disable output capturing. Otherwise, stdout is lost to doctest (#985)
114+ """
115+ if platform .system () != 'Darwin' :
116+ return
117+ capman = self .config .pluginmanager .getplugin ("capturemanager" )
118+ if capman :
119+ out , err = capman .suspend_global_capture (in_ = True )
120+ sys .stdout .write (out )
121+ sys .stderr .write (err )
122+
108123 def repr_failure (self , excinfo ):
109124 import doctest
110125 if excinfo .errisinstance ((doctest .DocTestFailure ,
Original file line number Diff line number Diff line change 1+ Fixed output capture handling in doctests on macOS.
Original file line number Diff line number Diff line change @@ -298,10 +298,6 @@ def test_2():
298298 child .read ()
299299 self .flush (child )
300300
301- # For some reason the interaction between doctest's and pytest's output
302- # capturing mechanisms are messing up the stdout on mac. (See #985).
303- # Should be solvable, but skipping until we have a chance to investigate.
304- @pytest .mark .xfail ("sys.platform == 'darwin'" , reason = 'See issue #985' , run = False )
305301 def test_pdb_interaction_doctest (self , testdir ):
306302 p1 = testdir .makepyfile ("""
307303 import pytest
You can’t perform that action at this time.
0 commit comments