Skip to content

PYTHON-3191 Fix test_sigstop_sigcont with Versioned API #916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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