@@ -147,29 +147,6 @@ def test_func():
147
147
assert rep .failed
148
148
assert len (pdblist ) == 1
149
149
150
- def test_pdb_interaction (self , testdir ):
151
- p1 = testdir .makepyfile (
152
- """
153
- def test_1():
154
- i = 0
155
- assert i == 1
156
-
157
- def test_not_called_due_to_quit():
158
- pass
159
- """
160
- )
161
- child = testdir .spawn_pytest ("--pdb %s" % p1 )
162
- child .expect (".*def test_1" )
163
- child .expect (".*i = 0" )
164
- child .expect ("Pdb" )
165
- child .sendeof ()
166
- rest = child .read ().decode ("utf8" )
167
- assert "= 1 failed in" in rest
168
- assert "def test_1" not in rest
169
- assert "Exit: Quitting debugger" in rest
170
- assert "PDB continue (IO-capturing resumed)" not in rest
171
- self .flush (child )
172
-
173
150
@staticmethod
174
151
def flush (child ):
175
152
if platform .system () == "Darwin" :
@@ -214,40 +191,32 @@ def test_one(self):
214
191
child .sendeof ()
215
192
self .flush (child )
216
193
217
- def test_pdb_print_captured_stdout (self , testdir ):
194
+ def test_pdb_print_captured_stdout_and_stderr (self , testdir ):
218
195
p1 = testdir .makepyfile (
219
196
"""
220
197
def test_1():
198
+ import sys
199
+ sys.stderr.write("get\\ x20rekt")
221
200
print("get\\ x20rekt")
222
201
assert False
202
+
203
+ def test_not_called_due_to_quit():
204
+ pass
223
205
"""
224
206
)
225
207
child = testdir .spawn_pytest ("--pdb %s" % p1 )
226
208
child .expect ("captured stdout" )
227
209
child .expect ("get rekt" )
228
- child .expect ("Pdb" )
229
- child .sendeof ()
230
- rest = child .read ().decode ("utf8" )
231
- assert "1 failed" in rest
232
- assert "get rekt" not in rest
233
- self .flush (child )
234
-
235
- def test_pdb_print_captured_stderr (self , testdir ):
236
- p1 = testdir .makepyfile (
237
- """
238
- def test_1():
239
- import sys
240
- sys.stderr.write("get\\ x20rekt")
241
- assert False
242
- """
243
- )
244
- child = testdir .spawn_pytest ("--pdb %s" % p1 )
245
210
child .expect ("captured stderr" )
246
211
child .expect ("get rekt" )
212
+ child .expect ("traceback" )
213
+ child .expect ("def test_1" )
247
214
child .expect ("Pdb" )
248
215
child .sendeof ()
249
216
rest = child .read ().decode ("utf8" )
250
- assert "1 failed" in rest
217
+ assert "Exit: Quitting debugger" in rest
218
+ assert "= 1 failed in" in rest
219
+ assert "def test_1" not in rest
251
220
assert "get rekt" not in rest
252
221
self .flush (child )
253
222
@@ -375,15 +344,17 @@ def test_1():
375
344
i = 0
376
345
print("hello17")
377
346
pytest.set_trace()
378
- x = 3
347
+ i == 1
348
+ assert 0
379
349
"""
380
350
)
381
351
child = testdir .spawn_pytest (str (p1 ))
382
- child .expect ("test_1" )
383
- child .expect ("x = 3 " )
352
+ child .expect (r "test_1\(\) " )
353
+ child .expect ("i == 1 " )
384
354
child .expect ("Pdb" )
385
- child .sendeof ( )
355
+ child .sendline ( "c" )
386
356
rest = child .read ().decode ("utf-8" )
357
+ assert "AssertionError" in rest
387
358
assert "1 failed" in rest
388
359
assert "def test_1" in rest
389
360
assert "hello17" in rest # out is captured
@@ -402,9 +373,9 @@ def test_1():
402
373
child .expect ("Pdb" )
403
374
child .sendeof ()
404
375
rest = child .read ().decode ("utf8" )
405
- assert "1 failed " in rest
376
+ assert "no tests ran " in rest
406
377
assert "reading from stdin while output" not in rest
407
- assert "BdbQuit" in rest
378
+ assert "BdbQuit" not in rest
408
379
self .flush (child )
409
380
410
381
def test_pdb_and_capsys (self , testdir ):
@@ -496,6 +467,7 @@ def test_1():
496
467
print("hello18")
497
468
pytest.set_trace()
498
469
x = 4
470
+ assert 0
499
471
"""
500
472
)
501
473
child = testdir .spawn_pytest (str (p1 ))
@@ -508,11 +480,11 @@ def test_1():
508
480
child .expect (r"PDB set_trace \(IO-capturing turned off\)" )
509
481
child .expect ("x = 4" )
510
482
child .expect ("Pdb" )
511
- child .sendeof ( )
483
+ child .sendline ( "c" )
512
484
child .expect ("_ test_1 _" )
513
485
child .expect ("def test_1" )
514
- child .expect ("Captured stdout call" )
515
486
rest = child .read ().decode ("utf8" )
487
+ assert "Captured stdout call" in rest
516
488
assert "hello17" in rest # out is captured
517
489
assert "hello18" in rest # out is captured
518
490
assert "1 failed" in rest
@@ -797,15 +769,26 @@ def test_trace_sets_breakpoint(self, testdir):
797
769
"""
798
770
def test_1():
799
771
assert True
772
+
773
+ def test_2():
774
+ pass
775
+
776
+ def test_3():
777
+ pass
800
778
"""
801
779
)
802
780
child = testdir .spawn_pytest ("--trace " + str (p1 ))
803
781
child .expect ("test_1" )
804
782
child .expect ("Pdb" )
805
- child .sendeof ()
783
+ child .sendline ("c" )
784
+ child .expect ("test_2" )
785
+ child .expect ("Pdb" )
786
+ child .sendline ("q" )
787
+ child .expect_exact ("Exit: Quitting debugger" )
806
788
rest = child .read ().decode ("utf8" )
807
- assert "1 passed" in rest
789
+ assert "1 passed in " in rest
808
790
assert "reading from stdin while output" not in rest
791
+ assert "Exit: Quitting debugger" in child .before .decode ("utf8" )
809
792
TestPDB .flush (child )
810
793
811
794
0 commit comments