Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51d01f7

Browse files
committed
TST: Restore original trace function
1 parent 1eeb3a4 commit 51d01f7

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

IPython/core/tests/test_debugger.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,19 @@ def raising_input(msg="", called=[0]):
247247
else:
248248
raise AssertionError("input() should only be called once!")
249249

250-
with patch.object(builtins, "input", raising_input):
251-
debugger.InterruptiblePdb().set_trace()
252-
# The way this test will fail is by set_trace() never exiting,
253-
# resulting in a timeout by the test runner. The alternative
254-
# implementation would involve a subprocess, but that adds issues with
255-
# interrupting subprocesses that are rather complex, so it's simpler
256-
# just to do it this way.
250+
tracer_orig = sys.gettrace()
251+
try:
252+
with patch.object(builtins, "input", raising_input):
253+
debugger.InterruptiblePdb().set_trace()
254+
# The way this test will fail is by set_trace() never exiting,
255+
# resulting in a timeout by the test runner. The alternative
256+
# implementation would involve a subprocess, but that adds issues
257+
# with interrupting subprocesses that are rather complex, so it's
258+
# simpler just to do it this way.
259+
finally:
260+
# restore the original trace function
261+
sys.settrace(tracer_orig)
262+
257263

258264
@skip_win32
259265
def test_xmode_skip():

0 commit comments

Comments
 (0)