예제 #1
0
파일: test.py 프로젝트: caktus/tracerlib
    def test_incall(self):
        self.tracer.watch('testmod.a')

        with self.tm:
            self.assertFalse(self.tracer.incall)
            def test():
                self.assertTrue(self.tracer.incall)
            with mock.patch('testmod.b', test):
                testmod.a()
예제 #2
0
    def test_incall(self):
        self.tracer.watch('testmod.a')

        with self.tm:
            self.assertFalse(self.tracer.incall)

            def test():
                self.assertTrue(self.tracer.incall)

            with mock.patch('testmod.b', test):
                testmod.a()
예제 #3
0
파일: test.py 프로젝트: caktus/tracerlib
    def test_child_tracer(self):
        t = mock.Mock()
        self.tracer.watch('testmod.a')
        child = tracerlib.Tracer(t, ['call'], ['testmod.b'], parent=self.tracer)
        self.tm.add(child)

        self.assertEqual(0, t.call_count, 'Tracer called before even enabling!')
        with self.tm:
            self.assertEqual(0, t.call_count, 'Tracer called before calling function!')
            testmod.b()
            self.assertEqual(0, t.call_count, 'Tracer called when parent was not in-call!')

        with self.tm:
            testmod.a()
            self.assertEqual(1, t.call_count)
예제 #4
0
    def test_child_tracer(self):
        t = mock.Mock()
        self.tracer.watch('testmod.a')
        child = tracerlib.Tracer(t, ['call'], ['testmod.b'],
                                 parent=self.tracer)
        self.tm.add(child)

        self.assertEqual(0, t.call_count,
                         'Tracer called before even enabling!')
        with self.tm:
            self.assertEqual(0, t.call_count,
                             'Tracer called before calling function!')
            testmod.b()
            self.assertEqual(0, t.call_count,
                             'Tracer called when parent was not in-call!')

        with self.tm:
            testmod.a()
            self.assertEqual(1, t.call_count)