当前位置: 首页>>代码示例>>Python>>正文


Python TempDirectory.atexit方法代码示例

本文整理汇总了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()
开发者ID:Simplistix,项目名称:testfixtures,代码行数:33,代码来源:test_tempdirectory.py

示例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()
开发者ID:yoyossy,项目名称:testfixtures__Simplistix,代码行数:12,代码来源:test_tempdirectory.py


注:本文中的testfixtures.TempDirectory.atexit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。