Skip to content

Commit 63a01bd

Browse files
committed
Factor out pytestPDB._is_capturing
1 parent d532099 commit 63a01bd

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/_pytest/debugging.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ class pytestPDB(object):
101101
_saved = []
102102
_recursive_debug = 0
103103

104+
@classmethod
105+
def _is_capturing(cls, capman):
106+
if capman:
107+
return capman.is_capturing()
108+
return False
109+
104110
@classmethod
105111
def _init_pdb(cls, *args, **kwargs):
106112
""" Initialize PDB debugging, dropping any IO capturing. """
@@ -118,10 +124,7 @@ def _init_pdb(cls, *args, **kwargs):
118124
if header is not None:
119125
tw.sep(">", header)
120126
else:
121-
if capman:
122-
capturing = capman.is_capturing()
123-
else:
124-
capturing = False
127+
capturing = cls._is_capturing(capman)
125128
if capturing:
126129
if capturing == "global":
127130
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
@@ -149,10 +152,9 @@ def do_continue(self, arg):
149152
if cls._recursive_debug == 0:
150153
tw = _pytest.config.create_terminal_writer(cls._config)
151154
tw.line()
152-
if self._pytest_capman:
153-
capturing = self._pytest_capman.is_capturing()
154-
else:
155-
capturing = False
155+
156+
capman = self._pytest_capman
157+
capturing = pytestPDB._is_capturing(capman)
156158
if capturing:
157159
if capturing == "global":
158160
tw.sep(">", "PDB continue (IO-capturing resumed)")
@@ -162,7 +164,7 @@ def do_continue(self, arg):
162164
"PDB continue (IO-capturing resumed for %s)"
163165
% capturing,
164166
)
165-
self._pytest_capman.resume()
167+
capman.resume()
166168
else:
167169
tw.sep(">", "PDB continue")
168170
cls._pluginmanager.hook.pytest_leave_pdb(

0 commit comments

Comments
 (0)