Skip to content

DRIVERS-3123 add test skip and clarification #1819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 21, 2025

Conversation

kevinAlbs
Copy link
Contributor

@kevinAlbs kevinAlbs commented Jul 17, 2025

Follow-up to #1812. Applies pending suggestions from review:

  • Allow drivers to skip the comparison test if the Vector type does not support comparison. The C driver's bson_vector_packed_bit_view_t does not support comparison.

  • Do not use Binary.from_vector in test example with non-zero ignored bits. PyMongo 4.14.0-dev raises an exception:

>>> b2 = Binary.from_vector([0b11111111], BinaryVectorDtype.PACKED_BIT, padding=7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kevin.albertson/code/mongo-python-driver/bson/binary.py", line 482, in from_vector
    raise ValueError(
ValueError: Vector has a padding P, but bits in the final byte lower than P are non-zero. They must be zero.

Please complete the following before merging:

  • [ ] Update changelog.
  • [ ] Test changes in at least one language driver.
  • [ ] Test these changes against all server versions and topologies (including standalone, replica set, and sharded
    clusters).

@kevinAlbs kevinAlbs requested a review from caseyclements July 17, 2025 13:20
@kevinAlbs kevinAlbs marked this pull request as ready for review July 17, 2025 13:21
@kevinAlbs kevinAlbs requested a review from a team as a code owner July 17, 2025 13:21
@kevinAlbs kevinAlbs requested review from JamesKovacs and removed request for a team July 17, 2025 13:21
assert b1 == Binary(b'\x10\x07\x80', subtype=9) # This is effectively a roundtrip.
v1 = Binary.as_vector(b1)
b1 = Binary(b'\x10\x07\x80', subtype=9)
b2 = Binary(b'\x10\x07\xff', subtype=9)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. Thank you for catching the oversight! I'd still like the example of equality though.

assert b1 == Binary.from_vector([0b10000000], BinaryVectorDtype.PACKED_BIT, padding=7)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added another value with the same data representation as b1 to add equality comparisons.

While here, I also realized it may not be reasonable to assume every driver may support constructing a Vector type with non-zero ignored bits. I added another condition to skip this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. Used the form b3 = Binary.from_vector([0b10000000], BinaryVectorDtype.PACKED_BIT, padding=7) to express the data in the base-literal notation.

@kevinAlbs kevinAlbs requested a review from caseyclements July 17, 2025 19:00
Copy link
Contributor

@caseyclements caseyclements left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@JamesKovacs JamesKovacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevinAlbs kevinAlbs merged commit c13d23b into mongodb:master Jul 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants