File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import umsgpack
22import struct
3+ import pytest
34
45single_test_vectors = [
56 # None
@@ -189,11 +190,7 @@ def test_pack_composite():
189190def test_pack_exceptions ():
190191 for (name , obj , exception ) in pack_exception_test_vectors :
191192 print ("\t Testing %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
198195def test_unpack_single ():
199196 for (name , obj , data ) in single_test_vectors :
@@ -208,9 +205,4 @@ def test_unpack_composite():
208205def test_unpack_exceptions ():
209206 for (name , data , exception ) in unpack_exception_test_vectors :
210207 print ("\t Testing %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 )
You can’t perform that action at this time.
0 commit comments