8000 remove too much parameterized tests · heruix/msgpack-python@6e36476 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e36476

Browse files
committed
remove too much parameterized tests
1 parent 3dad398 commit 6e36476

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

test/test_limits.py

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,39 @@
33
from __future__ import absolute_import, division, print_function, unicode_literals
44
import pytest
55

6-
from msgpack import packb, unpackb, Packer, Unpacker, ExtType, PackException, PackOverflowError, PackValueError
7-
from msgpack import UnpackValueError, UnpackException
6+
from msgpack import (
7+
packb, unpackb, Packer, Unpacker, ExtType,
8+
PackOverflowError, PackValueError, UnpackValueError,
9+
)
810

911

10-
@pytest.mark.parametrize("expected_exception", [OverflowError, ValueError, PackOverflowError,
11-
PackException, PackValueError])
12-
def test_integer(expected_exception):
12+
def test_integer():
1313
x = -(2 ** 63)
1414
assert unpackb(packb(x)) == x
15-
with pytest.raises(expected_exception):
15+
with pytest.raises(PackOverflowError):
1616
packb(x-1)
1717

1818
x = 2 ** 64 - 1
1919
assert unpackb(packb(x)) == x
20-
with pytest.raises(expected_exception):
20+
with pytest.raises(PackOverflowError):
2121
packb(x+1)
2222

2323

24-
@pytest.mark.parametrize("expected_exception", [ValueError, PackException, PackValueError])
25-
def test_array_header(expected_exception):
24+
def test_array_header():
2625
packer = Packer()
2726
packer.pack_array_header(2**32-1)
28-
with pytest.raises(expected_exception):
27+
with pytest.raises(PackValueError):
2928
packer.pack_array_header(2**32)
3029

3130

32-
@pytest.mark.parametrize("expected_exception", [ValueError, PackException, PackValueError])
33-
def test_map_header(expected_exception):
31+
def test_map_header():
3432
packer = Packer()
3533
packer.pack_map_header(2**32-1)
36-
with pytest.raises(expected_exception):
34+
with pytest.raises(PackValueError):
3735
packer.pack_array_header(2**32)
3836

3937

40-
@pytest.mark.parametrize("expected_exception", [ValueError, UnpackValueError, UnpackException])
41-
def test_max_str_len(expected_exception):
38+
def test_max_str_len():
4239
d = 'x' * 3
4340
packed = packb(d)
4441

@@ -47,13 +44,12 @@ def test_max_str_len(expected_exception):
4744
assert unpacker.unpack() == d
4845

4946
unpacker = Unpacker(max_str_len=2, encoding='utf-8')
50-
with pytest.raises(expected_exception):
47+
with pytest.raises(UnpackValueError):
5148
unpacker.feed(packed)
5249
unpacker.unpack()
5350

5451

55-
@pytest.mark.parametrize("expected_exception", [ValueError, UnpackValueError, UnpackException])
56-
def test_max_bin_len(expected_exception):
52+
def test_max_bin_len():
5753
d = b'x' * 3
5854
packed = packb(d, use_bin_type=True)
5955

@@ -62,13 +58,12 @@ def test_max_bin_len(expected_exception):
6258
assert unpacker.unpack() == d
6359

6460
unpacker = Unpacker(max_bin_len=2)
65-
with pytest.raises(expected_exception):
61+
with pytest.raises(UnpackValueError):
6662
unpacker.feed(packed)
6763
unpacker.unpack()
6864

6965

70-
@pytest.mark.parametrize("expected_exception", [ValueError, UnpackValueError, UnpackException])
71-
def test_max_array_len(expected_exception):
66+
def test_max_array_len():
7267
d = [1,2,3]
7368
packed = packb(d)
7469

@@ -77,13 +72,12 @@ def test_max_array_len(expected_exception):
7772
assert unpacker.unpack() == d
7873

7974
unpacker = Unpacker(max_array_len=2)
80-
with pytest.raises(expected_exception):
75+
with pytest.raises(UnpackValueError):
8176
unpacker.feed(packed)
8277
unpacker.unpack()
8378

8479

85-
@pytest.mark.parametrize("expected_exception", [ValueError, UnpackValueError, UnpackException])
86-
def test_max_map_len(expected_exception):
80+
def test_max_map_len():
8781
d = {1: 2, 3: 4, 5: 6}
8882
packed = packb(d)
8983

@@ -92,13 +86,12 @@ def test_max_map_len(expected_exception):
9286
assert unpacker.unpack() == d
9387

9488
unpacker = Unpacker(max_map_len=2)
95-
with pytest.raises(expected_exception):
89+
with pytest.raises(UnpackValueError):
9690
unpacker.feed(packed)
9791
unpacker.unpack()
9892

9993

100-
@pytest.mark.parametrize("expected_exception", [ValueError, UnpackValueError, UnpackException])
101-
def test_max_ext_len(expected_exception):
94+
def test_max_ext_len():
10295
d = ExtType(42, b"abc")
10396
packed = packb(d)
10497

@@ -107,7 +100,7 @@ def test_max_ext_len(expected_exception):
107100
assert unpacker.unpack() == d
108101

109102
unpacker = Unpacker(max_ext_len=2)
110-
with pytest.raises(expected_exception):
103+
with pytest.raises(UnpackValueError):
111104
unpacker.feed(packed)
112105
unpacker.unpack()
113106

0 commit comments

Comments
 (0)
0