File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff 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+
214221def test_write_jsonl_gzip ():
215222 """Tests writing data to a gzipped .jsonl file."""
216223 data = [{"hello" : "world" }, {"test" : 123 }]
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments