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 511865d commit 2edfc76Copy full SHA for 2edfc76
Lib/test/test_inspect.py
@@ -493,6 +493,15 @@ def test_getmodule(self):
493
# Check filename override
494
self.assertEqual(inspect.getmodule(None, modfile), mod)
495
496
+ def test_getmodule_file_not_found(self):
497
+ # See bpo-45406
498
+ def _getabsfile(obj, _filename):
499
+ raise FileNotFoundError('bad file')
500
+ with unittest.mock.patch('inspect.getabsfile', _getabsfile):
501
+ f = inspect.currentframe()
502
+ self.assertIsNone(inspect.getmodule(f))
503
+ inspect.getouterframes(f) # smoke test
504
+
505
def test_getframeinfo_get_first_line(self):
506
frame_info = inspect.getframeinfo(self.fodderModule.fr, 50)
507
self.assertEqual(frame_info.code_context[0], "# line 1\n")
0 commit comments