Skip to content

PYTHON-5342 Fix test_dns_failures test #2336

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 19 commits into from
May 8, 2025
5 changes: 3 additions & 2 deletions test/asynchronous/test_srv_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import time
from test.utils_shared import FunctionCallRecorder
from typing import Any
from unittest import skipIf

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

Expand Down Expand Up @@ -92,7 +91,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.disable()


@skipIf(not _IS_SYNC and sys.platform == "win32", "PYTHON-5342 known issue on Windows")
class TestSrvPolling(AsyncPyMongoTestCase):
BASE_SRV_RESPONSE = [
("localhost.test.build.10gen.cc", 27017),
Expand Down Expand Up @@ -186,6 +184,9 @@ def dns_resolver_response():
):
await assertion_method(expected_response, client)

# Close the client early to avoid affecting the next scenario run.
await client.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does leaving the client open have side effects?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed in office hours: the thought is that the patching was affecting the previous client(s) that were not yet garbage collected.


async def test_addition(self):
response = self.BASE_SRV_RESPONSE[:]
response.append(("localhost.test.build.10gen.cc", 27019))
Expand Down
5 changes: 3 additions & 2 deletions test/test_srv_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import time
from test.utils_shared import FunctionCallRecorder
from typing import Any
from unittest import skipIf

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

Expand Down Expand Up @@ -92,7 +91,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.disable()


@skipIf(not _IS_SYNC and sys.platform == "win32", "PYTHON-5342 known issue on Windows")
class TestSrvPolling(PyMongoTestCase):
BASE_SRV_RESPONSE = [
("localhost.test.build.10gen.cc", 27017),
Expand Down Expand Up @@ -186,6 +184,9 @@ def dns_resolver_response():
):
assertion_method(expected_response, client)

# Close the client early to avoid affecting the next scenario run.
client.close()

def test_addition(self):
response = self.BASE_SRV_RESPONSE[:]
response.append(("localhost.test.build.10gen.cc", 27019))
Expand Down
Loading