Skip to content

Commit 0e342a6

Browse files
committed
-
1 parent 0747e68 commit 0e342a6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

source_py3/test_python_toolbox/test_context_management/test_idempotentify.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def manage_context(self):
1313
self.x += 1
1414
try:
1515
yield (self, self)
16+
except ZeroDivisionError:
17+
pass
1618
finally:
1719
self.x -= 1
1820

@@ -45,6 +47,13 @@ def test_idempotentify():
4547
with cute_testing.RaiseAssertor():
4648
some_context_manager.__exit__(None, None, None)
4749

50+
with cute_testing.RaiseAssertor(KeyError):
51+
with some_context_manager:
52+
raise KeyError
53+
54+
with some_context_manager:
55+
raise ZeroDivisionError
56+
4857
###########################################################################
4958

5059

@@ -73,4 +82,10 @@ def test_idempotentify():
7382
idempotent_context_manager.__exit__(None, None, None)
7483
assert idempotent_context_manager.__wrapped__.x == 0
7584

85+
with cute_testing.RaiseAssertor(KeyError):
86+
with idempotent_context_manager:
87+
raise KeyError
88+
89+
with idempotent_context_manager:
90+
raise ZeroDivisionError
7691

0 commit comments

Comments
 (0)