Skip to content

Commit d7e5f3b

Browse files
committed
Addresses comments.
1 parent 093a6dc commit d7e5f3b

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

bson/binary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def as_vector(self) -> BinaryVector:
532532
unpacked_uint8s = list(struct.unpack_from(format_string, self, position))
533533
if padding and n_values and unpacked_uint8s[-1] & (1 << padding) - 1 != 0:
534534
warnings.warn(
535-
"Vector has a padding P, but bits in the final byte lower than P are non-zero. In the next major version, they must be zero.",
535+
"Vector has a padding P, but bits in the final byte lower than P are non-zero. For pymongo>=5.0, they must be zero.",
536536
DeprecationWarning,
537537
stacklevel=2,
538538
)

test/test_bson.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -784,20 +784,12 @@ def test_vector(self):
784784

785785
# Now some invalid cases
786786
for x in [-1, 257]:
787-
try:
787+
with self.assertRaises(struct.error):
788788
Binary.from_vector([x], BinaryVectorDtype.PACKED_BIT)
789-
except Exception as exc:
790-
self.assertIsInstance(exc, struct.error)
791-
else:
792-
self.fail("Failed to raise an exception.")
793789

794790
# Test one must pass zeros for all ignored bits
795-
try:
791+
with self.assertRaises(ValueError):
796792
Binary.from_vector([255], BinaryVectorDtype.PACKED_BIT, padding=7)
797-
except Exception as exc:
798-
self.assertIsInstance(exc, ValueError)
799-
else:
800-
self.fail("Failed to raise an exception.")
801793

802794
# Test form of Binary.from_vector(BinaryVector)
803795
assert padded_vec == Binary.from_vector(

0 commit comments

Comments
 (0)