@@ -48,7 +48,7 @@ def create_test(case_spec):
48
48
def run_test (self ):
49
49
for test_case in case_spec .get ("tests" , []):
50
50
description = test_case ["description" ]
51
- vector_exp = test_case .get ("vector" , [] )
51
+ vector_exp = test_case .get ("vector" )
52
52
dtype_hex_exp = test_case ["dtype_hex" ]
53
53
dtype_alias_exp = test_case .get ("dtype_alias" )
54
54
padding_exp = test_case .get ("padding" , 0 )
@@ -85,14 +85,26 @@ def run_test(self):
85
85
self .assertEqual (cB_obs , canonical_bson_exp , description )
86
86
87
87
else :
88
- with self .assertRaises ((struct .error , ValueError ), msg = description ):
89
- # Tests Binary.from_vector
90
- Binary .from_vector (vector_exp , dtype_exp , padding_exp )
91
- # Tests Binary.as_vector
92
- cB_exp = binascii .unhexlify (canonical_bson_exp .encode ("utf8" ))
93
- decoded_doc = decode (cB_exp )
94
- binary_obs = decoded_doc [test_key ]
95
- binary_obs .as_vector ()
88
+ """
89
+ #### To prove correct in an invalid case (`valid:false`), one MUST
90
+ - (encoding case) if the vector field is present, raise an exception
91
+ when attempting to encode a document from the numeric values,dtype, and padding.
92
+ - (decoding case) if the canonical_bson field is present, raise an exception
93
+ when attempting to deserialize it into the corresponding
94
+ numeric values, as the field contains corrupted data.
95
+ """
96
+ # Tests Binary.from_vector()
97
+ if vector_exp is not None :
98
+ with self .assertRaises ((struct .error , ValueError ), msg = description ):
99
+ Binary .from_vector (vector_exp , dtype_exp , padding_exp )
100
+
101
+ # Tests Binary.as_vector()
102
+ if canonical_bson_exp is not None :
103
+ with self .assertRaises ((struct .error , ValueError ), msg = description ):
104
+ cB_exp = binascii .unhexlify (canonical_bson_exp .encode ("utf8" ))
105
+ decoded_doc = decode (cB_exp )
106
+ binary_obs = decoded_doc [test_key ]
107
+ binary_obs .as_vector ()
96
108
97
109
return run_test
98
110
0 commit comments