Skip to content

Commit c3cdc27

Browse files
committed
added typing tests
1 parent 3d7ae53 commit c3cdc27

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/test_typing.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Test that each file in mypy_fails/ actually fails mypy, and test some
1616
sample client code that uses PyMongo typings.
1717
"""
18+
1819
from __future__ import annotations
1920

2021
import os
@@ -37,7 +38,8 @@
3738
if TYPE_CHECKING:
3839
from typing_extensions import NotRequired, TypedDict
3940

40-
from bson import ObjectId
41+
from bson import Binary, ObjectId
42+
from bson.binary import BinaryVector, BinaryVectorDtype
4143

4244
class Movie(TypedDict):
4345
name: str
@@ -591,5 +593,19 @@ def test_son_document_type(self) -> None:
591593
obj["a"] = 1
592594

593595

596+
class TestBSONFromVectorType(unittest.TestCase):
597+
def test_from_vector_binaryvector(self):
598+
list_vector = BinaryVector([127, 7], BinaryVectorDtype.INT8)
599+
Binary.from_vector(list_vector)
600+
601+
def test_from_vector_list_int(self):
602+
list_vector = [127, 7]
603+
Binary.from_vector(list_vector, BinaryVectorDtype.INT8)
604+
605+
def test_from_vector_list_float(self):
606+
list_vector = [127.0, 7.0]
607+
Binary.from_vector(list_vector, BinaryVectorDtype.INT8)
608+
609+
594610
if __name__ == "__main__":
595611
unittest.main()

0 commit comments

Comments
 (0)