Skip to content

Commit 56d7ea9

Browse files
committed
TST: Check more error messages in tests
Closes pandas-devgh-16521.
1 parent c55dbf0 commit 56d7ea9

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed
+13-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# coding: utf-8
22

3-
import pytest
4-
3+
from datetime import datetime
54
from pandas.io.msgpack import packb, unpackb
65

6+
import pytest
7+
import pandas.util.testing as tm
8+
79

810
class DummyException(Exception):
911
pass
@@ -12,12 +14,13 @@ class DummyException(Exception):
1214
class TestExceptions(object):
1315

1416
def test_raise_on_find_unsupported_value(self):
15-
import datetime
16-
pytest.raises(TypeError, packb, datetime.datetime.now())
17+
msg = "can\'t serialize datetime"
18+
with tm.assert_raises_regex(TypeError, msg):
19+
packb(datetime.now())
1720

1821
def test_raise_from_object_hook(self):
19-
def hook(obj):
20-
raise DummyException
22+
def hook(_):
23+
raise DummyException()
2124

2225
pytest.raises(DummyException, unpackb, packb({}), object_hook=hook)
2326
pytest.raises(DummyException, unpackb, packb({'fizz': 'buzz'}),
@@ -30,5 +33,7 @@ def hook(obj):
3033
packb({'fizz': {'buzz': 'spam'}}),
3134
object_pairs_hook=hook)
3235

33-
def test_invalidvalue(self):
34-
pytest.raises(ValueError, unpackb, b'\xd9\x97#DL_')
36+
def test_invalid_value(self):
37+
msg = "Unpack failed: error"
38+
with tm.assert_raises_regex(ValueError, msg):
39+
unpackb(b"\xd9\x97#DL_")

0 commit comments

Comments
 (0)