Skip to content

Commit

Permalink
Factor out pytestPDB._is_capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Mar 28, 2019
1 parent d532099 commit 63a01bd
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/_pytest/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ class pytestPDB(object):
_saved = []
_recursive_debug = 0

@classmethod
def _is_capturing(cls, capman):
if capman:
return capman.is_capturing()
return False

@classmethod
def _init_pdb(cls, *args, **kwargs):
""" Initialize PDB debugging, dropping any IO capturing. """
Expand All @@ -118,10 +124,7 @@ def _init_pdb(cls, *args, **kwargs):
if header is not None:
tw.sep(">", header)
else:
if capman:
capturing = capman.is_capturing()
else:
capturing = False
capturing = cls._is_capturing(capman)
if capturing:
if capturing == "global":
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
Expand Down Expand Up @@ -149,10 +152,9 @@ def do_continue(self, arg):
if cls._recursive_debug == 0:
tw = _pytest.config.create_terminal_writer(cls._config)
tw.line()
if self._pytest_capman:
capturing = self._pytest_capman.is_capturing()
else:
capturing = False

capman = self._pytest_capman
capturing = pytestPDB._is_capturing(capman)
if capturing:
if capturing == "global":
tw.sep(">", "PDB continue (IO-capturing resumed)")
Expand All @@ -162,7 +164,7 @@ def do_continue(self, arg):
"PDB continue (IO-capturing resumed for %s)"
% capturing,
)
self._pytest_capman.resume()
capman.resume()
else:
tw.sep(">", "PDB continue")
cls._pluginmanager.hook.pytest_leave_pdb(
Expand Down

0 comments on commit 63a01bd

Please sign in to comment.