Ensure our call stack test hits all function call opcodes
(self)
| 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") |