@@ -12,6 +12,26 @@ def runpdb_and_get_report(testdir, source):
12
12
return reports [1 ]
13
13
14
14
15
+ @pytest .fixture
16
+ def custom_pdb_calls ():
17
+ called = []
18
+
19
+ # install dummy debugger class and track which methods were called on it
20
+ class _CustomPdb :
21
+ def __init__ (self , * args , ** kwargs ):
22
+ called .append ("init" )
23
+
24
+ def reset (self ):
25
+ called .append ("reset" )
26
+
27
+ def interaction (self , * args ):
28
+ called .append ("interaction" )
29
+
30
+ _pytest ._CustomPdb = _CustomPdb
31
+ return called
32
+
33
+
34
+
15
35
class TestPDB :
16
36
17
37
@pytest .fixture
@@ -334,27 +354,23 @@ def test_foo():
334
354
if child .isalive ():
335
355
child .wait ()
336
356
337
- def test_pdb_custom_cls (self , testdir ):
338
- called = []
339
-
340
- # install dummy debugger class and track which methods were called on it
341
- class _CustomPdb :
342
- def __init__ (self , * args , ** kwargs ):
343
- called .append ("init" )
344
-
345
- def reset (self ):
346
- called .append ("reset" )
347
-
348
- def interaction (self , * args ):
349
- called .append ("interaction" )
357
+ def test_pdb_custom_cls (self , testdir , custom_pdb_calls ):
358
+ p1 = testdir .makepyfile ("""xxx """ )
359
+ result = testdir .runpytest_inprocess (
360
+ "--pdb" , "--pdbcls=_pytest:_CustomPdb" , p1 )
361
+ result .stdout .fnmatch_lines ([
362
+ "*NameError*xxx*" ,
363
+ "*1 error*" ,
364
+ ])
365
+ assert custom_pdb_calls == ["init" , "reset" , "interaction" ]
350
366
351
- _pytest ._CustomPdb = _CustomPdb
352
367
368
+ def test_pdb_custom_cls_without_pdb (self , testdir , custom_pdb_calls ):
353
369
p1 = testdir .makepyfile ("""xxx """ )
354
370
result = testdir .runpytest_inprocess (
355
371
"--pdbcls=_pytest:_CustomPdb" , p1 )
356
372
result .stdout .fnmatch_lines ([
357
373
"*NameError*xxx*" ,
358
374
"*1 error*" ,
359
375
])
360
- assert called == ["init" , "reset" , "interaction" ]
376
+ assert custom_pdb_calls == []
0 commit comments