Fix test
This commit is contained in:
parent
969abb2c15
commit
f2416507f0
@ -2268,15 +2268,14 @@ class AsyncMongoClient(common.BaseObject, Generic[_DocumentType]):
|
||||
self, session: Optional[client_session.AsyncClientSession]
|
||||
) -> AsyncGenerator[Optional[client_session.AsyncClientSession], None]:
|
||||
"""If provided session is None, lend a temporary session."""
|
||||
if session is not None and not isinstance(session, client_session.AsyncClientSession):
|
||||
raise ValueError(
|
||||
f"'session' argument must be an AsyncClientSession or None, not {type(session)}"
|
||||
)
|
||||
|
||||
# Check for a bound session. If one exists, treat it as an explicitly passed session.
|
||||
session = session or self._get_bound_session()
|
||||
|
||||
if session is not None:
|
||||
if not isinstance(session, client_session.AsyncClientSession):
|
||||
raise ValueError(
|
||||
f"'session' argument must be an AsyncClientSession or None, not {type(session)}"
|
||||
)
|
||||
if session:
|
||||
# Don't call end_session.
|
||||
yield session
|
||||
return
|
||||
|
||||
@ -2264,15 +2264,14 @@ class MongoClient(common.BaseObject, Generic[_DocumentType]):
|
||||
self, session: Optional[client_session.ClientSession]
|
||||
) -> Generator[Optional[client_session.ClientSession], None]:
|
||||
"""If provided session is None, lend a temporary session."""
|
||||
if session is not None and not isinstance(session, client_session.ClientSession):
|
||||
raise ValueError(
|
||||
f"'session' argument must be a ClientSession or None, not {type(session)}"
|
||||
)
|
||||
|
||||
# Check for a bound session. If one exists, treat it as an explicitly passed session.
|
||||
session = session or self._get_bound_session()
|
||||
|
||||
if session is not None:
|
||||
if not isinstance(session, client_session.ClientSession):
|
||||
raise ValueError(
|
||||
f"'session' argument must be a ClientSession or None, not {type(session)}"
|
||||
)
|
||||
if session:
|
||||
# Don't call end_session.
|
||||
yield session
|
||||
return
|
||||
|
||||
@ -877,6 +877,8 @@ class TestSession(AsyncIntegrationTest):
|
||||
|
||||
session1 = self.client.start_session()
|
||||
session2 = self.client.start_session()
|
||||
session1._materialize()
|
||||
session2._materialize()
|
||||
try:
|
||||
self.listener.reset()
|
||||
# Uses implicit session
|
||||
|
||||
@ -877,6 +877,8 @@ class TestSession(IntegrationTest):
|
||||
|
||||
session1 = self.client.start_session()
|
||||
session2 = self.client.start_session()
|
||||
session1._materialize()
|
||||
session2._materialize()
|
||||
try:
|
||||
self.listener.reset()
|
||||
# Uses implicit session
|
||||
|
||||
Loading…
Reference in New Issue
Block a user