def test_forget(self):
mod_filename = TESTFN + '.py'
with open(mod_filename, 'w') as f:
print('foo = 1', file=f)
sys.path.insert(0, os.curdir)
importlib.invalidate_caches()
try:
mod = __import__(TESTFN)
self.assertIn(TESTFN, sys.modules)
support.forget(TESTFN)
self.assertNotIn(TESTFN, sys.modules)
finally:
del sys.path[0]
support.unlink(mod_filename)
support.rmtree('__pycache__')
评论列表
文章目录