MCPcopy Index your code
hub / github.com/RustPython/RustPython / debug

Method debug

Lib/doctest.py:2346–2416  ·  view source on GitHub ↗

r"""Run the test case without results and without catching exceptions The unit test framework includes a debug method on test cases and test suites to support post-mortem debugging. The test code is run in such a way that errors are not caught. This way a

(self)

Source from the content-addressed store, hash-verified

2344 )
2345
2346 def debug(self):
2347 r"""Run the test case without results and without catching exceptions
2348
2349 The unit test framework includes a debug method on test cases
2350 and test suites to support post-mortem debugging. The test code
2351 is run in such a way that errors are not caught. This way a
2352 caller can catch the errors and initiate post-mortem debugging.
2353
2354 The DocTestCase provides a debug method that raises
2355 UnexpectedException errors if there is an unexpected
2356 exception:
2357
2358 >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42',
2359 ... {}, 'foo', 'foo.py', 0)
2360 >>> case = DocTestCase(test)
2361 >>> try:
2362 ... case.debug()
2363 ... except UnexpectedException as f:
2364 ... failure = f
2365
2366 The UnexpectedException contains the test, the example, and
2367 the original exception:
2368
2369 >>> failure.test is test
2370 True
2371
2372 >>> failure.example.want
2373 '42\n'
2374
2375 >>> exc_info = failure.exc_info
2376 >>> raise exc_info[1] # Already has the traceback
2377 Traceback (most recent call last):
2378 ...
2379 KeyError
2380
2381 If the output doesn't match, then a DocTestFailure is raised:
2382
2383 >>> test = DocTestParser().get_doctest('''
2384 ... >>> x = 1
2385 ... >>> x
2386 ... 2
2387 ... ''', {}, 'foo', 'foo.py', 0)
2388 >>> case = DocTestCase(test)
2389
2390 >>> try:
2391 ... case.debug()
2392 ... except DocTestFailure as f:
2393 ... failure = f
2394
2395 DocTestFailure objects provide access to the test:
2396
2397 >>> failure.test is test
2398 True
2399
2400 As well as to the example:
2401
2402 >>> failure.example.want
2403 '2\n'

Callers 1

make_archiveFunction · 0.45

Calls 4

setUpMethod · 0.95
runMethod · 0.95
tearDownMethod · 0.95
DebugRunnerClass · 0.85

Tested by

no test coverage detected