Merge pull request #3215 from pytest-dev/bugfix/985/disable-output-capturing-in-doctest
Disable output capturing in doctest
This commit is contained in:
commit
9d879bee36
|
@ -2,6 +2,8 @@
|
|||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import traceback
|
||||
import sys
|
||||
import platform
|
||||
|
||||
import pytest
|
||||
from _pytest._code.code import ExceptionInfo, ReprFileLocation, TerminalRepr
|
||||
|
@ -103,8 +105,21 @@ class DoctestItem(pytest.Item):
|
|||
|
||||
def runtest(self):
|
||||
_check_all_skipped(self.dtest)
|
||||
self._disable_output_capturing_for_darwin()
|
||||
self.runner.run(self.dtest)
|
||||
|
||||
def _disable_output_capturing_for_darwin(self):
|
||||
"""
|
||||
Disable output capturing. Otherwise, stdout is lost to doctest (#985)
|
||||
"""
|
||||
if platform.system() != 'Darwin':
|
||||
return
|
||||
capman = self.config.pluginmanager.getplugin("capturemanager")
|
||||
if capman:
|
||||
out, err = capman.suspend_global_capture(in_=True)
|
||||
sys.stdout.write(out)
|
||||
sys.stderr.write(err)
|
||||
|
||||
def repr_failure(self, excinfo):
|
||||
import doctest
|
||||
if excinfo.errisinstance((doctest.DocTestFailure,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fixed output capture handling in doctests on macOS.
|
|
@ -298,10 +298,6 @@ class TestPDB(object):
|
|||
child.read()
|
||||
self.flush(child)
|
||||
|
||||
# For some reason the interaction between doctest's and pytest's output
|
||||
# capturing mechanisms are messing up the stdout on mac. (See #985).
|
||||
# Should be solvable, but skipping until we have a chance to investigate.
|
||||
@pytest.mark.xfail("sys.platform == 'darwin'", reason='See issue #985', run=False)
|
||||
def test_pdb_interaction_doctest(self, testdir):
|
||||
p1 = testdir.makepyfile("""
|
||||
import pytest
|
||||
|
|
Loading…
Reference in New Issue