Skip to content

[3.6] bpo-32416: Add two new tests in test_sys_settrace. (GH-5072) #5073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions Lib/test/test_sys_settrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@ def test_jump_within_except_block(output):
output.append(6)
output.append(7)

@jump_test(2, 4, [1, 4, 5, -4])
def test_jump_across_with(output):
output.append(1)
with tracecontext(output, 2):
output.append(3)
with tracecontext(output, 4):
output.append(5)

@jump_test(8, 11, [1, 3, 5, 11, 12])
def test_jump_out_of_complex_nested_blocks(output):
output.append(1)
Expand Down Expand Up @@ -794,6 +802,17 @@ def test_jump_over_break_in_try_finally_block(output):
break
output.append(13)

@jump_test(1, 7, [7, 8])
def test_jump_over_for_block_before_else(output):
output.append(1)
if not output: # always false
for i in [3]:
output.append(4)
else:
output.append(6)
output.append(7)
output.append(8)

# The second set of 'jump' tests are for things that are not allowed:

@jump_test(2, 3, [1], (ValueError, 'after'))
Expand Down Expand Up @@ -951,21 +970,24 @@ def test_no_jump_out_of_finally_block(output):
finally:
output.append(5)

@jump_test(2, 4, [1, 4, 5, -4])
def test_jump_across_with(output):
@jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
def test_no_jump_between_with_blocks(output):
output.append(1)
with tracecontext(output, 2):
output.append(3)
with tracecontext(output, 4):
output.append(5)

@jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
def test_jump_across_with_2(output):
@jump_test(7, 4, [1, 6], (ValueError, 'into'))
def test_no_jump_into_for_block_before_else(output):
output.append(1)
with tracecontext(output, 2):
output.append(3)
with tracecontext(output, 4):
output.append(5)
if not output: # always false
for i in [3]:
output.append(4)
else:
output.append(6)
output.append(7)
output.append(8)

def test_no_jump_to_non_integers(self):
self.run_test(no_jump_to_non_integers, 2, "Spam", [True])
Expand Down