Show More
@@ -449,6 +449,24 b' class InteractiveShellTestCase(unittest.TestCase):' | |||
|
449 | 449 | # Reset the custom exception hook |
|
450 | 450 | ip.set_custom_exc((), None) |
|
451 | 451 | |
|
452 | @mock.patch('builtins.print') | |
|
453 | def test_showtraceback_with_surrogates(self, mocked_print): | |
|
454 | values = [] | |
|
455 | def mock_print_func(value, sep=' ', end='\n', file=sys.stdout, flush=False): | |
|
456 | values.append(value) | |
|
457 | if value == chr(0xd8ff): | |
|
458 | raise UnicodeEncodeError("utf-8", chr(0xd8ff), 0, 1, "") | |
|
459 | ||
|
460 | # mock builtins.print | |
|
461 | mocked_print.side_effect = mock_print_func | |
|
462 | ||
|
463 | # ip._showtraceback() is replaced in globalipapp.py. | |
|
464 | # Call original method to test. | |
|
465 | interactiveshell.InteractiveShell._showtraceback(ip, None, None, chr(0xd8ff)) | |
|
466 | ||
|
467 | self.assertEqual(mocked_print.call_count, 2) | |
|
468 | self.assertEqual(values, [chr(0xd8ff), '\\ud8ff']) | |
|
469 | ||
|
452 | 470 | def test_mktempfile(self): |
|
453 | 471 | filename = ip.mktempfile() |
|
454 | 472 | # Check that we can open the file again on Windows |
General Comments 0
You need to be logged in to leave comments.
Login now