bpo-32416: Add two new tests in test_sys_settrace. (#5072) · python/cpython@e8ed965 (original) (raw)
`@@ -789,6 +789,14 @@ def test_jump_within_except_block(output):
`
789
789
`output.append(6)
`
790
790
`output.append(7)
`
791
791
``
``
792
`+
@jump_test(2, 4, [1, 4, 5, -4])
`
``
793
`+
def test_jump_across_with(output):
`
``
794
`+
output.append(1)
`
``
795
`+
with tracecontext(output, 2):
`
``
796
`+
output.append(3)
`
``
797
`+
with tracecontext(output, 4):
`
``
798
`+
output.append(5)
`
``
799
+
792
800
`@jump_test(8, 11, [1, 3, 5, 11, 12])
`
793
801
`def test_jump_out_of_complex_nested_blocks(output):
`
794
802
`output.append(1)
`
`@@ -840,6 +848,17 @@ def test_jump_over_break_in_try_finally_block(output):
`
840
848
`break
`
841
849
`output.append(13)
`
842
850
``
``
851
`+
@jump_test(1, 7, [7, 8])
`
``
852
`+
def test_jump_over_for_block_before_else(output):
`
``
853
`+
output.append(1)
`
``
854
`+
if not output: # always false
`
``
855
`+
for i in [3]:
`
``
856
`+
output.append(4)
`
``
857
`+
else:
`
``
858
`+
output.append(6)
`
``
859
`+
output.append(7)
`
``
860
`+
output.append(8)
`
``
861
+
843
862
`# The second set of 'jump' tests are for things that are not allowed:
`
844
863
``
845
864
`@jump_test(2, 3, [1], (ValueError, 'after'))
`
`@@ -997,21 +1016,24 @@ def test_no_jump_out_of_finally_block(output):
`
997
1016
`finally:
`
998
1017
`output.append(5)
`
999
1018
``
1000
``
`-
@jump_test(2, 4, [1, 4, 5, -4])
`
1001
``
`-
def test_jump_across_with(output):
`
``
1019
`+
@jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
`
``
1020
`+
def test_no_jump_between_with_blocks(output):
`
1002
1021
`output.append(1)
`
1003
1022
`with tracecontext(output, 2):
`
1004
1023
`output.append(3)
`
1005
1024
`with tracecontext(output, 4):
`
1006
1025
`output.append(5)
`
1007
1026
``
1008
``
`-
@jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
`
1009
``
`-
def test_jump_across_with_2(output):
`
``
1027
`+
@jump_test(7, 4, [1, 6], (ValueError, 'into'))
`
``
1028
`+
def test_no_jump_into_for_block_before_else(output):
`
1010
1029
`output.append(1)
`
1011
``
`-
with tracecontext(output, 2):
`
1012
``
`-
output.append(3)
`
1013
``
`-
with tracecontext(output, 4):
`
1014
``
`-
output.append(5)
`
``
1030
`+
if not output: # always false
`
``
1031
`+
for i in [3]:
`
``
1032
`+
output.append(4)
`
``
1033
`+
else:
`
``
1034
`+
output.append(6)
`
``
1035
`+
output.append(7)
`
``
1036
`+
output.append(8)
`
1015
1037
``
1016
1038
`def test_no_jump_to_non_integers(self):
`
1017
1039
`self.run_test(no_jump_to_non_integers, 2, "Spam", [True])
`