File tree 2 files changed +35
-1
lines changed 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -128,8 +128,15 @@ def do_continue(self, arg):
128
128
do_c = do_cont = do_continue
129
129
130
130
def set_quit (self ):
131
+ """Raise Exit outcome when quit command is used in pdb.
132
+
133
+ This is a bit of a hack - it would be better if BdbQuit
134
+ could be handled, but this would require to wrap the
135
+ whole pytest run, and adjust the report etc.
136
+ """
131
137
super (_PdbWrapper , self ).set_quit ()
132
- outcomes .exit ("Quitting debugger" )
138
+ if cls ._recursive_debug == 0 :
139
+ outcomes .exit ("Quitting debugger" )
133
140
134
141
def setup (self , f , tb ):
135
142
"""Suspend on setup().
Original file line number Diff line number Diff line change @@ -954,3 +954,30 @@ def test_2():
954
954
rest = child .read ().decode ("utf8" )
955
955
assert "no tests ran" in rest
956
956
TestPDB .flush (child )
957
+
958
+
959
+ def test_pdb_quit_after_debug (testdir ):
960
+ p1 = testdir .makepyfile (
961
+ mytest = """
962
+ def foo():
963
+ pass
964
+
965
+ def test_1():
966
+ __import__('pdb').set_trace()
967
+ """
968
+ )
969
+ child = testdir .spawn_pytest (str (p1 ))
970
+ child .expect (r"\n\(Pdb" )
971
+ child .sendline ("debug foo()" )
972
+ child .expect ("ENTERING RECURSIVE DEBUGGER" )
973
+ child .expect (r"\n\(\(Pdb" )
974
+ child .sendline ("q" )
975
+ child .expect ("LEAVING RECURSIVE DEBUGGER" )
976
+ assert b"Quitting debugger" not in child .before
977
+ child .sendline ("q" )
978
+ rest = child .read ().decode ("utf8" )
979
+ # NOTE: there should be less trailing newlines with this probably, but
980
+ # this tests the current behavior.
981
+ assert "\r \n Exit: Quitting debugger\r \n \r \n \r \n "
982
+ assert "! _pytest.outcomes.Exit: Quitting debugger !" in rest
983
+ assert "= no tests ran in " in rest
You can’t perform that action at this time.
0 commit comments