def test_co_filename(self): self.writefile('mymodule.py', """ def get_co_filename(): return get_co_filename.func_code.co_filename """) import os expected = self.zipfile + os.sep + 'mymodule.py' # import mymodule co_filename = mymodule.get_co_filename() assert co_filename == expected # import zipimport z = zipimport.zipimporter(self.zipfile) code = z.get_code('mymodule') co_filename = code.co_filename assert co_filename == expected
def test_co_filename(self): self.writefile('mymodule.py', """ def get_co_filename(): return get_co_filename.__code__.co_filename """) import os expected = self.zipfile + os.sep + 'mymodule.py' # import mymodule co_filename = mymodule.get_co_filename() assert co_filename == expected # import zipimport z = zipimport.zipimporter(self.zipfile) code = z.get_code('mymodule') co_filename = code.co_filename assert co_filename == expected