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

Method test_traceback

Lib/test/_test_multiprocessing.py:2906–2942  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2904 raise RuntimeError(123) # some comment
2905
2906 def test_traceback(self):
2907 # We want ensure that the traceback from the child process is
2908 # contained in the traceback raised in the main process.
2909 if self.TYPE == 'processes':
2910 with self.Pool(1) as p:
2911 try:
2912 p.apply(self._test_traceback)
2913 except Exception as e:
2914 exc = e
2915 else:
2916 self.fail('expected RuntimeError')
2917 p.join()
2918 self.assertIs(type(exc), RuntimeError)
2919 self.assertEqual(exc.args, (123,))
2920 cause = exc.__cause__
2921 self.assertIs(type(cause), multiprocessing.pool.RemoteTraceback)
2922 self.assertIn('raise RuntimeError(123) # some comment', cause.tb)
2923
2924 with test.support.captured_stderr() as f1:
2925 try:
2926 raise exc
2927 except RuntimeError:
2928 sys.excepthook(*sys.exc_info())
2929 self.assertIn('raise RuntimeError(123) # some comment',
2930 f1.getvalue())
2931 # _helper_reraises_exception should not make the error
2932 # a remote exception
2933 with self.Pool(1) as p:
2934 try:
2935 p.map(sqr, exception_throwing_generator(1, -1), 1)
2936 except Exception as e:
2937 exc = e
2938 else:
2939 self.fail('expected SayWhenError')
2940 self.assertIs(type(exc), SayWhenError)
2941 self.assertIs(exc.__cause__, None)
2942 p.join()
2943
2944 @classmethod
2945 def _test_wrapped_exception(cls):

Callers

nothing calls this directly

Calls 10

assertInMethod · 0.80
PoolMethod · 0.45
applyMethod · 0.45
failMethod · 0.45
joinMethod · 0.45
assertIsMethod · 0.45
assertEqualMethod · 0.45
getvalueMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected