Skip to content

Commit

Permalink
PYTHON-3191 Fix test_sigstop_sigcont with Versioned API (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneHarvey committed Mar 31, 2022
1 parent 113d66d commit 1d6914f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def client_options(self):
def uri(self):
"""Return the MongoClient URI for creating a duplicate client."""
opts = client_context.default_client_options.copy()
opts.pop("server_api", None) # Cannot be set from the URI
opts_parts = []
for opt, val in opts.items():
strval = str(val)
Expand Down
8 changes: 8 additions & 0 deletions test/sigstop_sigcont.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@
"""Used by test_client.TestClient.test_sigstop_sigcont."""

import logging
import os
import sys

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

from pymongo import monitoring
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi

SERVER_API = None
MONGODB_API_VERSION = os.environ.get("MONGODB_API_VERSION")
if MONGODB_API_VERSION:
SERVER_API = ServerApi(MONGODB_API_VERSION)


class HeartbeatLogger(monitoring.ServerHeartbeatListener):
Expand Down Expand Up @@ -55,6 +62,7 @@ def main(uri: str) -> None:
event_listeners=[heartbeat_logger],
heartbeatFrequencyMS=500,
connectTimeoutMS=500,
server_api=SERVER_API,
)
client.admin.command("ping")
logging.info("TEST STARTED")
Expand Down

0 comments on commit 1d6914f

Please sign in to comment.