File tree 2 files changed +9
-0
lines changed 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):
284
284
def uri (self ):
285
285
"""Return the MongoClient URI for creating a duplicate client."""
286
286
opts = client_context .default_client_options .copy ()
287
+ opts .pop ("server_api" , None ) # Cannot be set from the URI
287
288
opts_parts = []
288
289
for opt , val in opts .items ():
289
290
strval = str (val )
Original file line number Diff line number Diff line change 15
15
"""Used by test_client.TestClient.test_sigstop_sigcont."""
16
16
17
17
import logging
18
+ import os
18
19
import sys
19
20
20
21
sys .path [0 :0 ] = ["" ]
21
22
22
23
from pymongo import monitoring
23
24
from 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 )
24
31
25
32
26
33
class HeartbeatLogger (monitoring .ServerHeartbeatListener ):
@@ -55,6 +62,7 @@ def main(uri: str) -> None:
55
62
event_listeners = [heartbeat_logger ],
56
63
heartbeatFrequencyMS = 500 ,
57
64
connectTimeoutMS = 500 ,
65
+ server_api = SERVER_API ,
58
66
)
59
67
client .admin .command ("ping" )
60
68
logging .info ("TEST STARTED" )
You can’t perform that action at this time.
0 commit comments