diff options
| author | INADA Naoki <methane@users.noreply.github.com> | 2016-02-14 17:08:13 +0900 |
|---|---|---|
| committer | INADA Naoki <methane@users.noreply.github.com> | 2016-02-14 17:08:13 +0900 |
| commit | f895517995754ce9bb758a77ea3db9ac7e6262c9 (patch) | |
| tree | 66c3c4472ac6530cb861cab553d045dc716fd082 /test | |
| parent | 82b31215079bc47bd4d5a8f3c18d83ac73c8221b (diff) | |
| parent | b2a8ce6cbdbef80d1a89d02fa483f56862cf1efa (diff) | |
| download | msgpack-python-f895517995754ce9bb758a77ea3db9ac7e6262c9.tar.gz | |
Merge pull request #172 from methane/palaviv-msgpack-exceptions
Organize Exceptions
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_limits.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/test/test_limits.py b/test/test_limits.py index 3c1cf2a..197ef46 100644 --- a/test/test_limits.py +++ b/test/test_limits.py @@ -3,32 +3,35 @@ from __future__ import absolute_import, division, print_function, unicode_literals import pytest -from msgpack import packb, unpackb, Packer, Unpacker, ExtType +from msgpack import ( + packb, unpackb, Packer, Unpacker, ExtType, + PackOverflowError, PackValueError, UnpackValueError, +) def test_integer(): x = -(2 ** 63) assert unpackb(packb(x)) == x - with pytest.raises((OverflowError, ValueError)): + with pytest.raises(PackOverflowError): packb(x-1) x = 2 ** 64 - 1 assert unpackb(packb(x)) == x - with pytest.raises((OverflowError, ValueError)): + with pytest.raises(PackOverflowError): packb(x+1) def test_array_header(): packer = Packer() packer.pack_array_header(2**32-1) - with pytest.raises((OverflowError, ValueError)): + with pytest.raises(PackValueError): packer.pack_array_header(2**32) def test_map_header(): packer = Packer() packer.pack_map_header(2**32-1) - with pytest.raises((OverflowError, ValueError)): + with pytest.raises(PackValueError): packer.pack_array_header(2**32) @@ -41,7 +44,7 @@ def test_max_str_len(): assert unpacker.unpack() == d unpacker = Unpacker(max_str_len=2, encoding='utf-8') - with pytest.raises(ValueError): + with pytest.raises(UnpackValueError): unpacker.feed(packed) unpacker.unpack() @@ -55,7 +58,7 @@ def test_max_bin_len(): assert unpacker.unpack() == d unpacker = Unpacker(max_bin_len=2) - with pytest.raises(ValueError): + with pytest.raises(UnpackValueError): unpacker.feed(packed) unpacker.unpack() @@ -69,7 +72,7 @@ def test_max_array_len(): assert unpacker.unpack() == d unpacker = Unpacker(max_array_len=2) - with pytest.raises(ValueError): + with pytest.raises(UnpackValueError): unpacker.feed(packed) unpacker.unpack() @@ -83,7 +86,7 @@ def test_max_map_len(): assert unpacker.unpack() == d unpacker = Unpacker(max_map_len=2) - with pytest.raises(ValueError): + with pytest.raises(UnpackValueError): unpacker.feed(packed) unpacker.unpack() @@ -97,7 +100,7 @@ def test_max_ext_len(): assert unpacker.unpack() == d unpacker = Unpacker(max_ext_len=2) - with pytest.raises(ValueError): + with pytest.raises(UnpackValueError): unpacker.feed(packed) unpacker.unpack() |
