Skip to content

Commit b622b63

Browse files
ShaneHarveyjuliusgeo
authored andcommitted
PYTHON-3191 Fix test_sigstop_sigcont with Versioned API (mongodb#916)
1 parent 7a7dfe6 commit b622b63

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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)

test/sigstop_sigcont.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@
1515
"""Used by test_client.TestClient.test_sigstop_sigcont."""
1616

1717
import logging
18+
import os
1819
import sys
1920

2021
sys.path[0:0] = [""]
2122

2223
from pymongo import monitoring
2324
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)
2431

2532

2633
class 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")

0 commit comments

Comments
 (0)