diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-01-01 18:51:30 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-01-01 18:51:30 (GMT) |
commit | 439ce8a93936d92e4f10765c482195a28e93ec76 (patch) | |
tree | 07983d887c05cf94e986a8bbb8b338e0f3f8be37 | |
parent | fe90efdc07ec70fd4ff28eac179448a41379cff1 (diff) | |
download | cpython-439ce8a93936d92e4f10765c482195a28e93ec76.zip cpython-439ce8a93936d92e4f10765c482195a28e93ec76.tar.gz cpython-439ce8a93936d92e4f10765c482195a28e93ec76.tar.bz2 |
bpo-32416: Add two new tests in test_sys_settrace. (GH-5072) (#5073)
Move other test to more proper place.
(cherry picked from commit e8ed96550c6aa9a1e39c36e67e892994e25e2c41)
-rw-r--r-- | Lib/test/test_sys_settrace.py | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 49fbf4d..5b3b066 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -743,6 +743,14 @@ class JumpTestCase(unittest.TestCase): 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) @@ -794,6 +802,17 @@ class JumpTestCase(unittest.TestCase): 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')) @@ -951,21 +970,24 @@ class JumpTestCase(unittest.TestCase): 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]) |