bpo-32416: Add two new tests in test_sys_settrace. (GH-5072) (#5074) · python/cpython@2de47ca (original) (raw)
`@@ -715,6 +715,14 @@ def test_jump_within_except_block(output):
`
715
715
`output.append(6)
`
716
716
`output.append(7)
`
717
717
``
``
718
`+
@jump_test(2, 4, [1, 4, 5, -4])
`
``
719
`+
def test_jump_across_with(output):
`
``
720
`+
output.append(1)
`
``
721
`+
with tracecontext(output, 2):
`
``
722
`+
output.append(3)
`
``
723
`+
with tracecontext(output, 4):
`
``
724
`+
output.append(5)
`
``
725
+
718
726
`@jump_test(8, 11, [1, 3, 5, 11, 12])
`
719
727
`def test_jump_out_of_complex_nested_blocks(output):
`
720
728
`output.append(1)
`
`@@ -766,6 +774,17 @@ def test_jump_over_break_in_try_finally_block(output):
`
766
774
`break
`
767
775
`output.append(13)
`
768
776
``
``
777
`+
@jump_test(1, 7, [7, 8])
`
``
778
`+
def test_jump_over_for_block_before_else(output):
`
``
779
`+
output.append(1)
`
``
780
`+
if not output: # always false
`
``
781
`+
for i in [3]:
`
``
782
`+
output.append(4)
`
``
783
`+
else:
`
``
784
`+
output.append(6)
`
``
785
`+
output.append(7)
`
``
786
`+
output.append(8)
`
``
787
+
769
788
`# The second set of 'jump' tests are for things that are not allowed:
`
770
789
``
771
790
`@jump_test(2, 3, [1], (ValueError, 'after'))
`
`@@ -911,21 +930,24 @@ def test_no_jump_out_of_finally_block(output):
`
911
930
`finally:
`
912
931
`output.append(5)
`
913
932
``
914
``
`-
@jump_test(2, 4, [1, 4, 5, -4])
`
915
``
`-
def test_jump_across_with(output):
`
``
933
`+
@jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
`
``
934
`+
def test_no_jump_between_with_blocks(output):
`
916
935
`output.append(1)
`
917
936
`with tracecontext(output, 2):
`
918
937
`output.append(3)
`
919
938
`with tracecontext(output, 4):
`
920
939
`output.append(5)
`
921
940
``
922
``
`-
@jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
`
923
``
`-
def test_jump_across_with_2(output):
`
``
941
`+
@jump_test(7, 4, [1, 6], (ValueError, 'into'))
`
``
942
`+
def test_no_jump_into_for_block_before_else(output):
`
924
943
`output.append(1)
`
925
``
`-
with tracecontext(output, 2):
`
926
``
`-
output.append(3)
`
927
``
`-
with tracecontext(output, 4):
`
928
``
`-
output.append(5)
`
``
944
`+
if not output: # always false
`
``
945
`+
for i in [3]:
`
``
946
`+
output.append(4)
`
``
947
`+
else:
`
``
948
`+
output.append(6)
`
``
949
`+
output.append(7)
`
``
950
`+
output.append(8)
`
929
951
``
930
952
`def test_no_jump_to_non_integers(self):
`
931
953
`self.run_test(no_jump_to_non_integers, 2, "Spam", [True])
`