Skip to content

Commit b929fd5

Browse files
committed
avoid cross-talk
1 parent e8834fb commit b929fd5

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

test/asynchronous/test_srv_polling.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def __init__(
5353
self.old_dns_resolver_response = None
5454

5555
def enable(self):
56-
print("enable")
5756
self.old_min_srv_rescan_interval = common.MIN_SRV_RESCAN_INTERVAL
5857
self.old_dns_resolver_response = (
5958
pymongo.asynchronous.srv_resolver._SrvResolver.get_hosts_and_min_ttl
@@ -83,7 +82,6 @@ def __enter__(self):
8382
self.enable()
8483

8584
def disable(self):
86-
print("disable")
8785
common.MIN_SRV_RESCAN_INTERVAL = self.old_min_srv_rescan_interval # type: ignore
8886
pymongo.asynchronous.srv_resolver._SrvResolver.get_hosts_and_min_ttl = ( # type: ignore
8987
self.old_dns_resolver_response
@@ -186,6 +184,9 @@ def dns_resolver_response():
186184
):
187185
await assertion_method(expected_response, client)
188186

187+
# Close the client early to avoid affecting the next scenario run.
188+
client.close()
189+
189190
async def test_addition(self):
190191
response = self.BASE_SRV_RESPONSE[:]
191192
response.append(("localhost.test.build.10gen.cc", 27019))
@@ -219,11 +220,7 @@ async def test_dns_failures(self):
219220
for exc in (exception.FormError, exception.Timeout, exception.TooBig):
220221

221222
def response_callback(*args):
222-
# raise exc("DNS Failure!")
223-
return []
224-
225-
print(exc)
226-
# await asyncio.sleep(0.5)
223+
raise exc("DNS Failure!")
227224

228225
await self.run_scenario(response_callback, False)
229226

test/test_srv_polling.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def __init__(
5353
self.old_dns_resolver_response = None
5454

5555
def enable(self):
56-
print("enable")
5756
self.old_min_srv_rescan_interval = common.MIN_SRV_RESCAN_INTERVAL
5857
self.old_dns_resolver_response = (
5958
pymongo.synchronous.srv_resolver._SrvResolver.get_hosts_and_min_ttl
@@ -83,7 +82,6 @@ def __enter__(self):
8382
self.enable()
8483

8584
def disable(self):
86-
print("disable")
8785
common.MIN_SRV_RESCAN_INTERVAL = self.old_min_srv_rescan_interval # type: ignore
8886
pymongo.synchronous.srv_resolver._SrvResolver.get_hosts_and_min_ttl = ( # type: ignore
8987
self.old_dns_resolver_response
@@ -186,6 +184,9 @@ def dns_resolver_response():
186184
):
187185
assertion_method(expected_response, client)
188186

187+
# Close the client early to avoid affecting the next scenario run.
188+
client.close()
189+
189190
def test_addition(self):
190191
response = self.BASE_SRV_RESPONSE[:]
191192
response.append(("localhost.test.build.10gen.cc", 27019))
@@ -219,11 +220,7 @@ def test_dns_failures(self):
219220
for exc in (exception.FormError, exception.Timeout, exception.TooBig):
220221

221222
def response_callback(*args):
222-
# raise exc("DNS Failure!")
223-
return []
224-
225-
print(exc)
226-
# time.sleep(0.5)
223+
raise exc("DNS Failure!")
227224

228225
self.run_scenario(response_callback, False)
229226

0 commit comments

Comments
 (0)