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

Method test_static_swaps_match_sequence

Lib/test/test_peepholer.py:802–815  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

800 self.assertNotInBytecode(code, "SWAP")
801
802 def test_static_swaps_match_sequence(self):
803 swaps = {"*_, b, c", "a, *_, c", "a, b, *_"}
804 forms = ["{}, {}, {}", "{}, {}, *{}", "{}, *{}, {}", "*{}, {}, {}"]
805 for a, b, c in product("_a", "_b", "_c"):
806 for form in forms:
807 pattern = form.format(a, b, c)
808 with self.subTest(pattern):
809 code = compile_pattern_with_fast_locals(pattern)
810 if pattern in swaps:
811 # If this fails... great! Remove this pattern from swaps
812 # to prevent regressing on any improvement:
813 self.assertInBytecode(code, "SWAP")
814 else:
815 self.assertNotInBytecode(code, "SWAP")
816
817
818class TestBuglets(unittest.TestCase):

Callers

nothing calls this directly

Calls 5

assertInBytecodeMethod · 0.80
assertNotInBytecodeMethod · 0.80
formatMethod · 0.45
subTestMethod · 0.45

Tested by

no test coverage detected