Exemplo n.º 1
0
    def test_get_oplimit_count(self):
        self.assertIsNone(tracer.get_opcode_limit())

        with tracer.limited_opcodes(100):
            self.assertEqual(tracer.get_opcode_limit(), 100)

        self.assertIsNone(tracer.get_opcode_limit())
Exemplo n.º 2
0
    def test_get_opcode_count(self):
        self.assertIsNone(tracer.get_opcode_count())

        with tracer.limited_opcodes(100):
            self.assertTrue(0 < tracer.get_opcode_count() < 100)

        self.assertIsNone(tracer.get_opcode_count())
Exemplo n.º 3
0
    def test_opcode_count(self):
        with tracer.limited_opcodes(100) as trace:
            self.f(10)

        self.assertTrue(0 < trace.opcode_count < 100)
Exemplo n.º 4
0
    def test_count_is_reset_on_each_call(self):
        with tracer.limited_opcodes(100):
            self.f(10)

        with tracer.limited_opcodes(100):
            self.f(10)
Exemplo n.º 5
0
 def test_exceeding_limit(self):
     with self.assertRaises(tracer.OpCodeLimitExceeded):
         with tracer.limited_opcodes(100):
             self.f(10)
             self.f(10)
Exemplo n.º 6
0
 def test_not_exceeding_limit(self):
     with tracer.limited_opcodes(100):
         self.f(10)