示例#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())
示例#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())
示例#3
0
    def test_opcode_count(self):
        with tracer.limited_opcodes(100) as trace:
            self.f(10)

        self.assertTrue(0 < trace.opcode_count < 100)
示例#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)
示例#5
0
 def test_exceeding_limit(self):
     with self.assertRaises(tracer.OpCodeLimitExceeded):
         with tracer.limited_opcodes(100):
             self.f(10)
             self.f(10)
示例#6
0
 def test_not_exceeding_limit(self):
     with tracer.limited_opcodes(100):
         self.f(10)