Skip to content

Commit b84438e

Browse files
committed
fix test
1 parent 7777659 commit b84438e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

test/asynchronous/test_max_staleness.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Test maxStalenessSeconds support."""
1616
from __future__ import annotations
1717

18+
import asyncio
1819
import os
1920
import sys
2021
import time
@@ -40,6 +41,7 @@
4041
else:
4142
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "max_staleness")
4243

44+
4345
class TestAllScenarios(create_selection_tests(TEST_PATH)): # type: ignore
4446
pass
4547

@@ -124,21 +126,22 @@ async def test_last_write_date(self):
124126
client = await self.async_rs_or_single_client(heartbeatFrequencyMS=500)
125127
await client.pymongo_test.test.insert_one({})
126128
# Wait for the server description to be updated.
127-
time.sleep(1)
129+
await asyncio.sleep(1)
128130
server = await client._topology.select_server(writable_server_selector, _Op.TEST)
129131
first = server.description.last_write_date
130132
self.assertTrue(first)
131133
# The first last_write_date may correspond to a internal server write,
132134
# sleep so that the next write does not occur within the same second.
133-
time.sleep(1)
135+
await asyncio.sleep(1)
134136
await client.pymongo_test.test.insert_one({})
135137
# Wait for the server description to be updated.
136-
time.sleep(1)
138+
await asyncio.sleep(1)
137139
server = await client._topology.select_server(writable_server_selector, _Op.TEST)
138140
second = server.description.last_write_date
139141
assert first is not None
140142

141143
assert second is not None
144+
print(second, first)
142145
self.assertGreater(second, first)
143146
self.assertLess(second, first + 10)
144147

test/test_max_staleness.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Test maxStalenessSeconds support."""
1616
from __future__ import annotations
1717

18+
import asyncio
1819
import os
1920
import sys
2021
import time
@@ -40,6 +41,7 @@
4041
else:
4142
TEST_PATH = os.path.join(Path(__file__).resolve().parent.parent, "max_staleness")
4243

44+
4345
class TestAllScenarios(create_selection_tests(TEST_PATH)): # type: ignore
4446
pass
4547

@@ -139,6 +141,7 @@ def test_last_write_date(self):
139141
assert first is not None
140142

141143
assert second is not None
144+
print(second, first)
142145
self.assertGreater(second, first)
143146
self.assertLess(second, first + 10)
144147

0 commit comments

Comments
 (0)