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


Python util._Janitor函数代码示例

本文整理汇总了Python中twisted.trial.util._Janitor函数的典型用法代码示例。如果您正苦于以下问题:Python _Janitor函数的具体用法?Python _Janitor怎么用?Python _Janitor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_Janitor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _cleanUp

 def _cleanUp(self, result):
     try:
         if self.forceGarbageCollection:
             gc.collect()
         util._Janitor().postCaseCleanup()
     except util.FailureError, e:
         result.addError(self, e.original)
         self._passed = False
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:8,代码来源:unittest.py

示例2: test_cleanReactorKillsProcesses

    def test_cleanReactorKillsProcesses(self):
        """
        The Janitor will kill processes during reactor cleanup.
        """
        @implementer(IProcessTransport)
        class StubProcessTransport(object):
            """
            A stub L{IProcessTransport} provider which records signals.
            @ivar signals: The signals passed to L{signalProcess}.
            """

            def __init__(self):
                self.signals = []

            def signalProcess(self, signal):
                """
                Append C{signal} to C{self.signals}.
                """
                self.signals.append(signal)

        pt = StubProcessTransport()
        reactor = StubReactor([], [pt])
        jan = _Janitor(None, None, reactor=reactor)
        jan._cleanReactor()
        self.assertEqual(pt.signals, ["KILL"])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:25,代码来源:test_util.py

示例3: test_cleanReactorRemovesSelectables

 def test_cleanReactorRemovesSelectables(self):
     """
     The Janitor will remove selectables during reactor cleanup.
     """
     reactor = StubReactor([])
     jan = _Janitor(None, None, reactor=reactor)
     jan._cleanReactor()
     self.assertEqual(reactor.removeAllCalled, 1)
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:8,代码来源:test_util.py

示例4: testBenchmark

    def testBenchmark(self):
        from twisted.trial.test.common import BogusReporter
        from twisted import trial
        
        suite = runner.TestSuite(BogusReporter(), util._Janitor(), benchmark=True)
        suite.addTestClass(self.Benchmark)
        suite.run()

        stats = pickle.load(file('test.stats', 'rb'))
        failUnlessEqual(stats, {reflect.qual(self.Benchmark.benchmarkValues): statdatum})
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:10,代码来源:test_trial.py

示例5: test_postClassCleanupNoErrors

 def test_postClassCleanupNoErrors(self):
     """
     The post-class cleanup method will not call C{addError} on the result
     if there are no pending calls or selectables.
     """
     reactor = StubReactor([])
     test = object()
     reporter = StubErrorReporter()
     jan = _Janitor(test, reporter, reactor=reactor)
     jan.postClassCleanup()
     self.assertEqual(reporter.errors, [])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:11,代码来源:test_util.py

示例6: test_postCaseCleanupNoErrors

 def test_postCaseCleanupNoErrors(self):
     """
     The post-case cleanup method will return True and not call C{addError}
     on the result if there are no pending calls.
     """
     reactor = StubReactor([])
     test = object()
     reporter = StubErrorReporter()
     jan = _Janitor(test, reporter, reactor=reactor)
     self.assertTrue(jan.postCaseCleanup())
     self.assertEqual(reporter.errors, [])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:11,代码来源:test_util.py

示例7: test_cleanPendingSpinsReactor

 def test_cleanPendingSpinsReactor(self):
     """
     During pending-call cleanup, the reactor will be spun twice with an
     instant timeout. This is not a requirement, it is only a test for
     current behavior. Hopefully Trial will eventually not do this kind of
     reactor stuff.
     """
     reactor = StubReactor([])
     jan = _Janitor(None, None, reactor=reactor)
     jan._cleanPending()
     self.assertEqual(reactor.iterations, [0, 0])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:11,代码来源:test_util.py

示例8: test_cleanPendingCancelsCalls

 def test_cleanPendingCancelsCalls(self):
     """
     During pending-call cleanup, the janitor cancels pending timed calls.
     """
     def func():
         return "Lulz"
     cancelled = []
     delayedCall = DelayedCall(300, func, (), {},
                               cancelled.append, lambda x: None)
     reactor = StubReactor([delayedCall])
     jan = _Janitor(None, None, reactor=reactor)
     jan._cleanPending()
     self.assertEqual(cancelled, [delayedCall])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:13,代码来源:test_util.py

示例9: test_postClassCleanupWithSelectableErrors

 def test_postClassCleanupWithSelectableErrors(self):
     """
     The post-class cleanup method call C{addError} on the result with a
     L{DirtyReactorAggregateError} Failure if there are selectables.
     """
     selectable = "SELECTABLE HERE"
     reactor = StubReactor([], [selectable])
     test = object()
     reporter = StubErrorReporter()
     jan = _Janitor(test, reporter, reactor=reactor)
     jan.postClassCleanup()
     self.assertEqual(len(reporter.errors), 1)
     self.assertEqual(reporter.errors[0][1].value.selectables, [repr(selectable)])
开发者ID:pombredanne,项目名称:toppatch,代码行数:13,代码来源:test_util.py

示例10: test_postClassCleanupWithPendingCallErrors

 def test_postClassCleanupWithPendingCallErrors(self):
     """
     The post-class cleanup method call C{addError} on the result with a
     L{DirtyReactorAggregateError} Failure if there are pending calls.
     """
     delayedCall = DelayedCall(300, lambda: None, (), {}, lambda x: None, lambda x: None, seconds=lambda: 0)
     delayedCallString = str(delayedCall)
     reactor = StubReactor([delayedCall], [])
     test = object()
     reporter = StubErrorReporter()
     jan = _Janitor(test, reporter, reactor=reactor)
     jan.postClassCleanup()
     self.assertEqual(len(reporter.errors), 1)
     self.assertEqual(reporter.errors[0][1].value.delayedCalls, [delayedCallString])
开发者ID:pombredanne,项目名称:toppatch,代码行数:14,代码来源:test_util.py

示例11: test_cleanPendingReturnsDelayedCallStrings

 def test_cleanPendingReturnsDelayedCallStrings(self):
     """
     The Janitor produces string representations of delayed calls from the
     delayed call cleanup method. It gets the string representations
     *before* cancelling the calls; this is important because cancelling the
     call removes critical debugging information from the string
     representation.
     """
     delayedCall = DelayedCall(300, lambda: None, (), {}, lambda x: None, lambda x: None, seconds=lambda: 0)
     delayedCallString = str(delayedCall)
     reactor = StubReactor([delayedCall])
     jan = _Janitor(None, None, reactor=reactor)
     strings = jan._cleanPending()
     self.assertEqual(strings, [delayedCallString])
开发者ID:pombredanne,项目名称:toppatch,代码行数:14,代码来源:test_util.py

示例12: testMethods

    def testMethods(self):
        from twisted.trial.test.common import BogusReporter
        for klass in (self.Tests,
                      self.TestSkipClassAttr,
                      self.TestTodoClassAttr):
            suite = runner.TestSuite(BogusReporter(), util._Janitor())
            suite.addTestClass(klass)
            suite.run()

            for method in suite.methods:
                try:
                    self.checkResults(method)
                except unittest.FailTest:
                    raise
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:14,代码来源:test_tests.py

示例13: _cleanUp

 def _cleanUp(self, result):
     try:
         clean = util._Janitor(self, result).postCaseCleanup()
         if not clean:
             self._passed = False
     except:
         result.addError(self, failure.Failure())
         self._passed = False
     for error in self._observer.getErrors():
         result.addError(self, error)
         self._passed = False
     self.flushLoggedErrors()
     self._removeObserver()
     if self._passed:
         result.addSuccess(self)
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:15,代码来源:_asynctest.py

示例14: test_cleanReactorReturnsSelectableStrings

    def test_cleanReactorReturnsSelectableStrings(self):
        """
        The Janitor returns string representations of the selectables that it
        cleaned up from the reactor cleanup method.
        """
        class Selectable(object):
            """
            A stub Selectable which only has an interesting string
            representation.
            """
            def __repr__(self):
                return "(SELECTABLE!)"

        reactor = StubReactor([], [Selectable()])
        jan = _Janitor(None, None, reactor=reactor)
        self.assertEqual(jan._cleanReactor(), ["(SELECTABLE!)"])
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:16,代码来源:test_util.py

示例15: setUp

 def setUp(self):
     self.janitor = util._Janitor()
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:2,代码来源:test_util.py


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