diff --git a/test/bson_binary_vector/float32.json b/test/bson_binary_vector/float32.json index 845f504ff3..72dafce10f 100644 --- a/test/bson_binary_vector/float32.json +++ b/test/bson_binary_vector/float32.json @@ -32,7 +32,7 @@ { "description": "Infinity Vector FLOAT32", "valid": true, - "vector": ["-inf", 0.0, "inf"], + "vector": [{"$numberDouble": "-Infinity"}, 0.0, {"$numberDouble": "Infinity"} ], "dtype_hex": "0x27", "dtype_alias": "FLOAT32", "padding": 0, diff --git a/test/test_bson_binary_vector.py b/test/test_bson_binary_vector.py index a49f515fea..9bfdcbfb9a 100644 --- a/test/test_bson_binary_vector.py +++ b/test/test_bson_binary_vector.py @@ -16,12 +16,11 @@ import binascii import codecs -import json import struct from pathlib import Path from test import unittest -from bson import decode, encode +from bson import decode, encode, json_util from bson.binary import Binary, BinaryVectorDtype _TEST_PATH = Path(__file__).parent / "bson_binary_vector" @@ -62,9 +61,6 @@ def run_test(self): cB_exp = binascii.unhexlify(canonical_bson_exp.encode("utf8")) decoded_doc = decode(cB_exp) binary_obs = decoded_doc[test_key] - # Handle special float cases like '-inf' - if dtype_exp in [BinaryVectorDtype.FLOAT32]: - vector_exp = [float(x) for x in vector_exp] # Test round-tripping canonical bson. self.assertEqual(encode(decoded_doc), cB_exp, description) @@ -104,7 +100,7 @@ def run_test(self): def create_tests(): for filename in _TEST_PATH.glob("*.json"): with codecs.open(str(filename), encoding="utf-8") as test_file: - test_method = create_test(json.load(test_file)) + test_method = create_test(json_util.loads(test_file.read())) setattr(TestBSONBinaryVector, "test_" + filename.stem, test_method)