MCPcopy Index your code
hub / github.com/python/cpython / test_contains_op_dict

Method test_contains_op_dict

Lib/test/test_capi/test_opt.py:2398–2413  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2396 self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
2397
2398 def test_contains_op_dict(self):
2399 def testfunc(n):
2400 x = 0
2401 d = {'a': 1, 'b': 2}
2402 for _ in range(n):
2403 if 'a' in d:
2404 x += 1
2405 return x
2406
2407 res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
2408 self.assertEqual(res, TIER2_THRESHOLD)
2409 self.assertIsNotNone(ex)
2410 uops = get_opnames(ex)
2411 self.assertIn("_CONTAINS_OP_DICT", uops)
2412 self.assertIn("_POP_TOP_NOP", uops)
2413 self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
2414
2415 def test_call_type_1_guards_removed(self):
2416 def testfunc(n):

Callers

nothing calls this directly

Calls 7

_run_with_optimizerMethod · 0.95
get_opnamesFunction · 0.85
count_opsFunction · 0.85
assertIsNotNoneMethod · 0.80
assertInMethod · 0.80
assertLessEqualMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected