Skip to content

Commit 751949a

Browse files
authored
PYTHON-3316 Add Type Check Test for Transactions (#995)
1 parent 256cd00 commit 751949a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/test_mypy.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Movie(TypedDict): # type: ignore[misc]
4747
from pymongo.collection import Collection
4848
from pymongo.mongo_client import MongoClient
4949
from pymongo.operations import InsertOne
50+
from pymongo.read_preferences import ReadPreference
5051

5152
TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "mypy_fails")
5253

@@ -163,6 +164,15 @@ class mydict(Dict[str, Any]):
163164
)
164165
self.assertTrue(len(list(result)))
165166

167+
def test_with_transaction(self) -> None:
168+
def execute_transaction(session):
169+
pass
170+
171+
with self.client.start_session() as session:
172+
return session.with_transaction(
173+
execute_transaction, read_preference=ReadPreference.PRIMARY
174+
)
175+
166176

167177
class TestDecode(unittest.TestCase):
168178
def test_bson_decode(self) -> None:

0 commit comments

Comments
 (0)