summaryrefslogtreecommitdiff
path: root/Lib/test/test_sys_settrace.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_sys_settrace.py')
-rw-r--r--Lib/test/test_sys_settrace.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 83b03925c3..4298986250 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -916,6 +916,46 @@ class TraceTestCase(unittest.TestCase):
(7, 'line'),
(7, 'return')])
+ def test_if_false_in_with(self):
+
+ class C:
+ def __enter__(self):
+ return self
+ def __exit__(*args):
+ pass
+
+ def func():
+ with C():
+ if False:
+ pass
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (-5, 'call'),
+ (-4, 'line'),
+ (-4, 'return'),
+ (2, 'line'),
+ (-3, 'call'),
+ (-2, 'line'),
+ (-2, 'return'),
+ (2, 'return')])
+
+ def test_if_false_in_try_except(self):
+
+ def func():
+ try:
+ if False:
+ pass
+ except Exception:
+ X
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (2, 'return')])
+
class SkipLineEventsTraceTestCase(TraceTestCase):
"""Repeat the trace tests, but with per-line events skipped"""