pdb: improve msg about output capturing with set_trace
Do not display "IO-capturing turned off/on" when ``-s`` is used to avoid confusion.
This commit is contained in:
parent
233c2a23de
commit
e0038b82f7
|
@ -102,6 +102,9 @@ class CaptureManager(object):
|
||||||
|
|
||||||
# Global capturing control
|
# Global capturing control
|
||||||
|
|
||||||
|
def is_globally_capturing(self):
|
||||||
|
return self._method != "no"
|
||||||
|
|
||||||
def start_global_capturing(self):
|
def start_global_capturing(self):
|
||||||
assert self._global_capturing is None
|
assert self._global_capturing is None
|
||||||
self._global_capturing = self._getcapture(self._method)
|
self._global_capturing = self._getcapture(self._method)
|
||||||
|
|
|
@ -80,7 +80,10 @@ class pytestPDB(object):
|
||||||
capman.suspend_global_capture(in_=True)
|
capman.suspend_global_capture(in_=True)
|
||||||
tw = _pytest.config.create_terminal_writer(cls._config)
|
tw = _pytest.config.create_terminal_writer(cls._config)
|
||||||
tw.line()
|
tw.line()
|
||||||
|
if capman and capman.is_globally_capturing():
|
||||||
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
|
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
|
||||||
|
else:
|
||||||
|
tw.sep(">", "PDB set_trace")
|
||||||
|
|
||||||
class _PdbWrapper(cls._pdb_cls, object):
|
class _PdbWrapper(cls._pdb_cls, object):
|
||||||
_pytest_capman = capman
|
_pytest_capman = capman
|
||||||
|
@ -91,7 +94,10 @@ class pytestPDB(object):
|
||||||
if self._pytest_capman:
|
if self._pytest_capman:
|
||||||
tw = _pytest.config.create_terminal_writer(cls._config)
|
tw = _pytest.config.create_terminal_writer(cls._config)
|
||||||
tw.line()
|
tw.line()
|
||||||
|
if self._pytest_capman.is_globally_capturing():
|
||||||
tw.sep(">", "PDB continue (IO-capturing resumed)")
|
tw.sep(">", "PDB continue (IO-capturing resumed)")
|
||||||
|
else:
|
||||||
|
tw.sep(">", "PDB continue")
|
||||||
self._pytest_capman.resume_global_capture()
|
self._pytest_capman.resume_global_capture()
|
||||||
cls._pluginmanager.hook.pytest_leave_pdb(
|
cls._pluginmanager.hook.pytest_leave_pdb(
|
||||||
config=cls._config, pdb=self
|
config=cls._config, pdb=self
|
||||||
|
|
|
@ -518,6 +518,22 @@ class TestPDB(object):
|
||||||
assert "1 failed" in rest
|
assert "1 failed" in rest
|
||||||
self.flush(child)
|
self.flush(child)
|
||||||
|
|
||||||
|
def test_pdb_without_capture(self, testdir):
|
||||||
|
p1 = testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
def test_1():
|
||||||
|
pytest.set_trace()
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
child = testdir.spawn_pytest("-s %s" % p1)
|
||||||
|
child.expect(r">>> PDB set_trace >>>")
|
||||||
|
child.expect("Pdb")
|
||||||
|
child.sendline("c")
|
||||||
|
child.expect(r">>> PDB continue >>>")
|
||||||
|
child.expect("1 passed")
|
||||||
|
self.flush(child)
|
||||||
|
|
||||||
def test_pdb_used_outside_test(self, testdir):
|
def test_pdb_used_outside_test(self, testdir):
|
||||||
p1 = testdir.makepyfile(
|
p1 = testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue