示例#1
0
 def setUp(self):
     super(_AbstractTestPeriodicMonitoringThread, self).setUp()
     self._orig_start_new_thread = monitor.start_new_thread
     self._orig_thread_sleep = monitor.thread_sleep
     monitor.thread_sleep = lambda _s: gc.collect() # For PyPy
     monitor.start_new_thread = lambda _f, _a: 0xDEADBEEF
     self.hub = MockHub()
     self.pmt = monitor.PeriodicMonitoringThread(self.hub)
     self.pmt_default_funcs = self.pmt.monitoring_functions()[:]
     self.len_pmt_default_funcs = len(self.pmt_default_funcs)
示例#2
0
    def test_previous_trace(self):
        self.pmt.kill()
        self.assertIsNone(gettrace())

        called = []
        def f(*args):
            called.append(args)

        settrace(f)

        self.pmt = monitor.PeriodicMonitoringThread(self.hub)
        self.assertEqual(gettrace(), self.pmt.greenlet_trace)
        self.assertIs(self.pmt.previous_trace_function, f)

        self.pmt.greenlet_trace('event', 'args')

        self.assertEqual([('event', 'args')], called)