3
3
import pudb
4
4
import sys
5
5
import warnings
6
+ import _pytest .unittest
6
7
7
8
8
9
def pytest_addoption (parser ):
@@ -26,6 +27,7 @@ def __init__(self, config):
26
27
self .config = config
27
28
self .pluginmanager = config .pluginmanager
28
29
self ._pudb_get_debugger = None
30
+ self ._test_case_function_runtest = None
29
31
30
32
@property
31
33
def with_pudb_option (self ):
@@ -38,11 +40,25 @@ def mount(self):
38
40
if self .with_pudb_option :
39
41
self .config .pluginmanager .register (self , 'pudb_wrapper' )
40
42
43
+ def runtest (self ):
44
+ # disables tearDown and cleanups for post mortem debugging
45
+ # see: https://github.com/pytest-dev/pytest/pull/1890
46
+ if self ._handle_skip ():
47
+ return
48
+ self ._testcase .debug ()
49
+
50
+ self ._test_case_function_runtest = _pytest .unittest .TestCaseFunction .runtest
51
+ _pytest .unittest .TestCaseFunction .runtest = runtest
52
+
41
53
def unmount (self ):
42
54
if self ._pudb_get_debugger :
43
55
pudb ._get_debugger = self ._pudb_get_debugger
44
56
self ._pudb_get_debugger = None
45
57
58
+ if self ._test_case_function_runtest :
59
+ _pytest .unittest .TestCaseFunction .runtest = self ._test_case_function_runtest
60
+ self ._test_case_function_runtest = None
61
+
46
62
def disable_io_capture (self ):
47
63
if self .pluginmanager is not None :
48
64
capman = self .pluginmanager .getplugin ("capturemanager" )
0 commit comments