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