Skip to content

Commit 496aaa5

Browse files
committed
Use pytest.raises
1 parent caaf0cd commit 496aaa5

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

test_umsgpack.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import umsgpack
22
import struct
3+
import pytest
34

45
single_test_vectors = [
56
# None
@@ -189,11 +190,7 @@ def test_pack_composite():
189190
def test_pack_exceptions():
190191
for (name, obj, exception) in pack_exception_test_vectors:
191192
print("\tTesting %s: object %s" % (name, str(obj) if len(str(obj)) < 24 else str(obj)[0:24] + "..."))
192-
try:
193-
_ = umsgpack.packb(obj)
194-
assert False
195-
except Exception as e:
196-
assert isinstance(e, exception)
193+
with pytest.raises(exception): umsgpack.packb(obj)
197194

198195
def test_unpack_single():
199196
for (name, obj, data) in single_test_vectors:
@@ -208,9 +205,4 @@ def test_unpack_composite():
208205
def test_unpack_exceptions():
209206
for (name, data, exception) in unpack_exception_test_vectors:
210207
print("\tTesting %s" % name)
211-
try:
212-
_ = umsgpack.unpackb(data)
213-
assert False
214-
except Exception as e:
215-
assert isinstance(e, exception)
216-
208+
with pytest.raises(exception): umsgpack.unpackb(data)

0 commit comments

Comments
 (0)