Skip to content

Commit f71c206

Browse files
committed
Reinstated bunch of tests
1 parent d8b93b9 commit f71c206

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

srsly/tests/test_json_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ def test_unsupported_type_error():
211211
s = json_dumps({1, 2})
212212

213213

214+
def test_unsupported_type_error_numpy():
215+
numpy = pytest.importorskip("numpy")
216+
f = numpy.float32()
217+
with pytest.raises(TypeError, match="is not JSON serializable"):
218+
s = json_dumps(f)
219+
220+
214221
def test_write_jsonl_gzip():
215222
"""Tests writing data to a gzipped .jsonl file."""
216223
data = [{"hello": "world"}, {"test": 123}]

srsly/tests/test_msgpack_api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ def test_msgpack_complex():
6363
assert type(out["a"]) is complex
6464

6565

66-
def test_msgpack_unknown_types():
67-
"""Test that msgpack raises correct errors (e.g. when serializing
68-
datetime objects, the error should be msgpack's TypeError,
69-
not a "'np' is not defined error").
70-
"""
66+
def test_msgpack_without_numpy():
67+
"""Test that msgpack works with and without numpy and raises correct errors (e.g.
68+
when serializing datetime objects, the error should be msgpack's TypeError,
69+
not a "'np' is not defined error")."""
7170
with pytest.raises(TypeError, match="datetime.datetime"):
7271
msgpack_dumps(datetime.datetime.now())
7372

0 commit comments

Comments
 (0)