|
16 | 16 |
|
17 | 17 | import binascii
|
18 | 18 | import codecs
|
19 |
| -import json |
20 | 19 | import struct
|
21 | 20 | from pathlib import Path
|
22 | 21 | from test import unittest
|
23 | 22 |
|
24 |
| -from bson import decode, encode |
| 23 | +from bson import decode, encode, json_util |
25 | 24 | from bson.binary import Binary, BinaryVectorDtype
|
26 | 25 |
|
27 | 26 | _TEST_PATH = Path(__file__).parent / "bson_binary_vector"
|
@@ -62,9 +61,6 @@ def run_test(self):
|
62 | 61 | cB_exp = binascii.unhexlify(canonical_bson_exp.encode("utf8"))
|
63 | 62 | decoded_doc = decode(cB_exp)
|
64 | 63 | binary_obs = decoded_doc[test_key]
|
65 |
| - # Handle special float cases like '-inf' |
66 |
| - if dtype_exp in [BinaryVectorDtype.FLOAT32]: |
67 |
| - vector_exp = [float(x) for x in vector_exp] |
68 | 64 |
|
69 | 65 | # Test round-tripping canonical bson.
|
70 | 66 | self.assertEqual(encode(decoded_doc), cB_exp, description)
|
@@ -104,7 +100,7 @@ def run_test(self):
|
104 | 100 | def create_tests():
|
105 | 101 | for filename in _TEST_PATH.glob("*.json"):
|
106 | 102 | with codecs.open(str(filename), encoding="utf-8") as test_file:
|
107 |
| - test_method = create_test(json.load(test_file)) |
| 103 | + test_method = create_test(json_util.loads(test_file.read())) |
108 | 104 | setattr(TestBSONBinaryVector, "test_" + filename.stem, test_method)
|
109 | 105 |
|
110 | 106 |
|
|
0 commit comments