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

Method test_verify_call_opcodes

Lib/test/test_dtrace.py:127–150  ·  view source on GitHub ↗

Ensure our call stack test hits all function call opcodes

(self)

Source from the content-addressed store, hash-verified

125 self.run_case("call_stack")
126
127 def test_verify_call_opcodes(self):
128 """Ensure our call stack test hits all function call opcodes"""
129
130 opcodes = set(["CALL_FUNCTION", "CALL_FUNCTION_EX", "CALL_FUNCTION_KW"])
131
132 with open(abspath("call_stack.py")) as f:
133 code_string = f.read()
134
135 def get_function_instructions(funcname):
136 # Recompile with appropriate optimization setting
137 code = compile(source=code_string,
138 filename="<string>",
139 mode="exec",
140 optimize=self.optimize_python)
141
142 for c in code.co_consts:
143 if isinstance(c, types.CodeType) and c.co_name == funcname:
144 return dis.get_instructions(c)
145 return []
146
147 for instruction in get_function_instructions('start'):
148 opcodes.discard(instruction.opname)
149
150 self.assertEqual(set(), opcodes)
151
152 def test_gc(self):
153 self.run_case("gc")

Callers

nothing calls this directly

Calls 6

setFunction · 0.85
abspathFunction · 0.70
openFunction · 0.50
readMethod · 0.45
discardMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected