diff options
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_dis.py | 2 | ||||
| -rw-r--r-- | Lib/test/test_sys_settrace.py | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 0383124464..e342a14bf0 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1026,7 +1026,7 @@ expected_opinfo_jumpy = [ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=42, argval=42, argrepr='', offset=36, starts_line=None, is_jump_target=False), Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=38, starts_line=8, is_jump_target=False), Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=52, argval=52, argrepr='', offset=40, starts_line=None, is_jump_target=False), - Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=8, argval=8, argrepr='', offset=42, starts_line=None, is_jump_target=True), + Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=8, argval=8, argrepr='', offset=42, starts_line=7, is_jump_target=True), Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=44, starts_line=10, is_jump_target=True), Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=46, starts_line=None, is_jump_target=False), Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=48, starts_line=None, is_jump_target=False), diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 83b03925c3..4298986250 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -916,6 +916,46 @@ class TraceTestCase(unittest.TestCase): (7, 'line'), (7, 'return')]) + def test_if_false_in_with(self): + + class C: + def __enter__(self): + return self + def __exit__(*args): + pass + + def func(): + with C(): + if False: + pass + + self.run_and_compare(func, + [(0, 'call'), + (1, 'line'), + (-5, 'call'), + (-4, 'line'), + (-4, 'return'), + (2, 'line'), + (-3, 'call'), + (-2, 'line'), + (-2, 'return'), + (2, 'return')]) + + def test_if_false_in_try_except(self): + + def func(): + try: + if False: + pass + except Exception: + X + + self.run_and_compare(func, + [(0, 'call'), + (1, 'line'), + (2, 'line'), + (2, 'return')]) + class SkipLineEventsTraceTestCase(TraceTestCase): """Repeat the trace tests, but with per-line events skipped""" |
