diff options
author | Mark Shannon <mark@hotpy.org> | 2021-06-03 19:57:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 19:57:31 +0100 |
commit | cea0585b7939b487d7089f9d473f495264e8a491 (patch) | |
tree | f9a174a273315c61ff049bcb77fb292b8a5744f6 /Lib/test/test_sys_settrace.py | |
parent | 84d80f5f30b1f545083c70a7d4e1e79ab75f9fa6 (diff) | |
download | cpython-git-cea0585b7939b487d7089f9d473f495264e8a491.tar.gz |
[3.10] bpo-44298: Backport #26513 to 3.10 (#26516)
* Backport 937cebc93 to 3.10
* Update importlib
Diffstat (limited to 'Lib/test/test_sys_settrace.py')
-rw-r--r-- | Lib/test/test_sys_settrace.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 3296ee0139..0174f80dce 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -995,6 +995,52 @@ class TraceTestCase(unittest.TestCase): (5, 'line'), (5, 'return')]) + def test_early_exit_with(self): + + class C: + def __enter__(self): + return self + def __exit__(*args): + pass + + def func_break(): + for i in (1,2): + with C(): + break + pass + + def func_return(): + with C(): + return + + self.run_and_compare(func_break, + [(0, 'call'), + (1, 'line'), + (2, 'line'), + (-5, 'call'), + (-4, 'line'), + (-4, 'return'), + (3, 'line'), + (2, 'line'), + (-3, 'call'), + (-2, 'line'), + (-2, 'return'), + (4, 'line'), + (4, 'return')]) + + self.run_and_compare(func_return, + [(0, 'call'), + (1, 'line'), + (-11, 'call'), + (-10, 'line'), + (-10, 'return'), + (2, 'line'), + (1, 'line'), + (-9, 'call'), + (-8, 'line'), + (-8, 'return'), + (1, 'return')]) + class SkipLineEventsTraceTestCase(TraceTestCase): """Repeat the trace tests, but with per-line events skipped""" |