本文整理汇总了Python中testfixtures.TempDirectory.atexit方法的典型用法代码示例。如果您正苦于以下问题:Python TempDirectory.atexit方法的具体用法?Python TempDirectory.atexit怎么用?Python TempDirectory.atexit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testfixtures.TempDirectory
的用法示例。
在下文中一共展示了TempDirectory.atexit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_atexit
# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import atexit [as 别名]
def test_atexit(self):
# http://bugs.python.org/issue25532
from testfixtures.mock import call
m = Mock()
with Replacer() as r:
# make sure the marker is false, other tests will
# probably have set it
r.replace('testfixtures.TempDirectory.atexit_setup', False)
r.replace('atexit.register', m.register)
d = TempDirectory()
expected = [call.register(d.atexit)]
compare(expected, m.mock_calls)
with catch_warnings(record=True) as w:
d.atexit()
self.assertTrue(len(w), 1)
compare(str(w[0].message), ( # pragma: no branch
"TempDirectory instances not cleaned up by shutdown:\n" +
d.path
))
d.cleanup()
compare(set(), TempDirectory.instances)
# check re-running has no ill effects
d.atexit()
示例2: test_atexit
# 需要导入模块: from testfixtures import TempDirectory [as 别名]
# 或者: from testfixtures.TempDirectory import atexit [as 别名]
def test_atexit(self):
d = TempDirectory()
self.assertTrue(TempDirectory.atexit in [t[0] for t in atexit._exithandlers])
with catch_warnings(record=True) as w:
d.atexit()
self.assertTrue(len(w), 1)
compare(str(w[0].message), ("TempDirectory instances not cleaned up by shutdown:\n" + d.path))
d.cleanup()
# call again to make sure nothing blows up:
d.atexit()