本文整理汇总了Python中test.support.forget方法的典型用法代码示例。如果您正苦于以下问题:Python support.forget方法的具体用法?Python support.forget怎么用?Python support.forget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.support
的用法示例。
在下文中一共展示了support.forget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_forget
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import forget [as 别名]
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__')
示例2: test_forget
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import forget [as 别名]
def test_forget(self):
mod_filename = TESTFN + '.py'
with open(mod_filename, 'wt') as f:
f.write('foo = 1\n')
sys.path.insert(0, os.curdir)
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__')
示例3: test_empty_namespace_package
# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import forget [as 别名]
def test_empty_namespace_package(self):
pkg_name = 'doctest_empty_pkg'
with tempfile.TemporaryDirectory() as parent_dir:
pkg_dir = os.path.join(parent_dir, pkg_name)
os.mkdir(pkg_dir)
sys.path.append(parent_dir)
try:
mod = importlib.import_module(pkg_name)
finally:
support.forget(pkg_name)
sys.path.pop()
assert doctest.DocTestFinder().find(mod) == []