File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,7 @@ def client_options(self):
284284 def uri (self ):
285285 """Return the MongoClient URI for creating a duplicate client."""
286286 opts = client_context .default_client_options .copy ()
287+ opts .pop ("server_api" , None ) # Cannot be set from the URI
287288 opts_parts = []
288289 for opt , val in opts .items ():
289290 strval = str (val )
Original file line number Diff line number Diff line change 1515"""Used by test_client.TestClient.test_sigstop_sigcont."""
1616
1717import logging
18+ import os
1819import sys
1920
2021sys .path [0 :0 ] = ["" ]
2122
2223from pymongo import monitoring
2324from pymongo .mongo_client import MongoClient
25+ from pymongo .server_api import ServerApi
26+
27+ SERVER_API = None
28+ MONGODB_API_VERSION = os .environ .get ("MONGODB_API_VERSION" )
29+ if MONGODB_API_VERSION :
30+ SERVER_API = ServerApi (MONGODB_API_VERSION )
2431
2532
2633class HeartbeatLogger (monitoring .ServerHeartbeatListener ):
@@ -55,6 +62,7 @@ def main(uri: str) -> None:
5562 event_listeners = [heartbeat_logger ],
5663 heartbeatFrequencyMS = 500 ,
5764 connectTimeoutMS = 500 ,
65+ server_api = SERVER_API ,
5866 )
5967 client .admin .command ("ping" )
6068 logging .info ("TEST STARTED" )
You can’t perform that action at this time.
0 commit comments