summaryrefslogtreecommitdiff
path: root/tests/run/withstat_py.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/withstat_py.py')
-rw-r--r--tests/run/withstat_py.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/run/withstat_py.py b/tests/run/withstat_py.py
index 53197dc04..3cc327fb2 100644
--- a/tests/run/withstat_py.py
+++ b/tests/run/withstat_py.py
@@ -205,3 +205,23 @@ def manager_from_expression():
g = GetManager()
with g.get(2) as x:
print(x)
+
+def manager_from_ternary(use_first):
+ """
+ >>> manager_from_ternary(True)
+ enter
+ exit <type 'type'> <type 'ValueError'> <type 'traceback'>
+ >>> manager_from_ternary(False)
+ enter
+ exit <type 'type'> <type 'ValueError'> <type 'traceback'>
+ In except
+ """
+ # This is mostly testing a parsing problem, hence the
+ # result of the ternary must be callable
+ cm1_getter = lambda: ContextManager("1", exit_ret=True)
+ cm2_getter = lambda: ContextManager("2")
+ try:
+ with (cm1_getter if use_first else cm2_getter)():
+ raise ValueError
+ except ValueError:
+ print("In except")