Skip to content

Commit 4068a36

Browse files
committed
Use assertRaises
1 parent b6ce407 commit 4068a36

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

tests/snippets/try_exceptions.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,14 @@ def __init__(self):
126126
except ZeroDivisionError as ex:
127127
assert type(ex.__cause__) == NameError
128128

129-
try:
129+
with assertRaises(NameError):
130130
try:
131131
raise NameError
132132
except:
133133
raise
134-
except NameError:
135-
pass
136134

137-
try:
135+
with assertRaises(RuntimeError):
138136
raise
139-
except RuntimeError:
140-
pass
141137

142138
context = None
143139
try:

0 commit comments

Comments
 (0)