File tree Expand file tree Collapse file tree 4 files changed +31
-2
lines changed Expand file tree Collapse file tree 4 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1+ pdb: improve message about output capturing with ``set_trace ``.
2+
3+ Do not display "IO-capturing turned off/on" when ``-s `` is used to avoid
4+ confusion.
Original file line number Diff line number Diff line change @@ -102,6 +102,9 @@ def _getcapture(self, method):
102102
103103 # Global capturing control
104104
105+ def is_globally_capturing (self ):
106+ return self ._method != "no"
107+
105108 def start_global_capturing (self ):
106109 assert self ._global_capturing is None
107110 self ._global_capturing = self ._getcapture (self ._method )
Original file line number Diff line number Diff line change @@ -80,7 +80,10 @@ def set_trace(cls, set_break=True):
8080 capman .suspend_global_capture (in_ = True )
8181 tw = _pytest .config .create_terminal_writer (cls ._config )
8282 tw .line ()
83- tw .sep (">" , "PDB set_trace (IO-capturing turned off)" )
83+ if capman and capman .is_globally_capturing ():
84+ tw .sep (">" , "PDB set_trace (IO-capturing turned off)" )
85+ else :
86+ tw .sep (">" , "PDB set_trace" )
8487
8588 class _PdbWrapper (cls ._pdb_cls , object ):
8689 _pytest_capman = capman
@@ -91,7 +94,10 @@ def do_continue(self, arg):
9194 if self ._pytest_capman :
9295 tw = _pytest .config .create_terminal_writer (cls ._config )
9396 tw .line ()
94- tw .sep (">" , "PDB continue (IO-capturing resumed)" )
97+ if self ._pytest_capman .is_globally_capturing ():
98+ tw .sep (">" , "PDB continue (IO-capturing resumed)" )
99+ else :
100+ tw .sep (">" , "PDB continue" )
95101 self ._pytest_capman .resume_global_capture ()
96102 cls ._pluginmanager .hook .pytest_leave_pdb (
97103 config = cls ._config , pdb = self
Original file line number Diff line number Diff line change @@ -518,6 +518,22 @@ def test_1():
518518 assert "1 failed" in rest
519519 self .flush (child )
520520
521+ def test_pdb_without_capture (self , testdir ):
522+ p1 = testdir .makepyfile (
523+ """
524+ import pytest
525+ def test_1():
526+ pytest.set_trace()
527+ """
528+ )
529+ child = testdir .spawn_pytest ("-s %s" % p1 )
530+ child .expect (r">>> PDB set_trace >>>" )
531+ child .expect ("Pdb" )
532+ child .sendline ("c" )
533+ child .expect (r">>> PDB continue >>>" )
534+ child .expect ("1 passed" )
535+ self .flush (child )
536+
521537 def test_pdb_used_outside_test (self , testdir ):
522538 p1 = testdir .makepyfile (
523539 """
You can’t perform that action at this time.
0 commit comments