We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9aa6631 commit f0aec1fCopy full SHA for f0aec1f
Lib/test/test_traceback.py
@@ -5456,5 +5456,17 @@ def test_suggestion_still_works_for_non_lazy_attributes(self):
5456
self.assertNotIn(b"BAR_MODULE_LOADED", stdout)
5457
5458
5459
+class TestNoCrashInTracebackException(unittest.TestCase):
5460
+ def test_module_not_found_error_with_bad_name(self):
5461
+ exc = ModuleNotFoundError(name=NotImplemented)
5462
+ try:
5463
+ te = traceback.TracebackException.from_exception(exc)
5464
+ except Exception as e:
5465
+ self.fail(f"TracebackException raised unexpected exception: {e!r}")
5466
+ else:
5467
+ msg = "".join(te.format())
5468
+ self.assertEqual(msg, "ModuleNotFoundError\n")
5469
+
5470
5471
if __name__ == "__main__":
5472
unittest.main()
0 commit comments