mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
Fix SF#1516184 and add a test to prevent regression.
This commit is contained in:
parent
b9cb84fe96
commit
5d86bdb3ae
2 changed files with 19 additions and 12 deletions
|
|
@ -178,6 +178,16 @@ class TestRetrievingSourceCode(GetSourceBase):
|
|||
def test_getfile(self):
|
||||
self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
|
||||
|
||||
def test_getmodule_recursion(self):
|
||||
from new import module
|
||||
name = '__inspect_dummy'
|
||||
m = sys.modules[name] = module(name)
|
||||
m.__file__ = "<string>" # hopefully not a real filename...
|
||||
m.__loader__ = "dummy" # pretend the filename is understood by a loader
|
||||
exec "def x(): pass" in m.__dict__
|
||||
self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>')
|
||||
del sys.modules[name]
|
||||
|
||||
class TestDecorators(GetSourceBase):
|
||||
fodderFile = mod2
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue