Skip to content

Commit 4742737

Browse files
authored
PYTHON-4643 Fix test_to_list_tailable (mongodb#1783)
1 parent 940d2c8 commit 4742737

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

test/asynchronous/test_cursor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,6 @@ async def test_getMore_does_not_send_readPreference(self):
13801380
self.assertEqual("getMore", started[1].command_name)
13811381
self.assertNotIn("$readPreference", started[1].command)
13821382

1383-
@async_client_context.require_version_min(4, 0)
13841383
@async_client_context.require_replica_set
13851384
async def test_to_list_tailable(self):
13861385
oplog = self.client.local.oplog.rs
@@ -1391,7 +1390,10 @@ async def test_to_list_tailable(self):
13911390
{"ts": {"$gte": ts}}, cursor_type=pymongo.CursorType.TAILABLE_AWAIT, oplog_replay=True
13921391
).max_await_time_ms(1)
13931392
self.addAsyncCleanup(c.close)
1394-
docs = await c.to_list()
1393+
# Wait for the change to be read.
1394+
docs = []
1395+
while not docs:
1396+
docs = await c.to_list()
13951397
self.assertGreaterEqual(len(docs), 1)
13961398

13971399
async def test_to_list_empty(self):

test/test_cursor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,6 @@ def test_getMore_does_not_send_readPreference(self):
13711371
self.assertEqual("getMore", started[1].command_name)
13721372
self.assertNotIn("$readPreference", started[1].command)
13731373

1374-
@client_context.require_version_min(4, 0)
13751374
@client_context.require_replica_set
13761375
def test_to_list_tailable(self):
13771376
oplog = self.client.local.oplog.rs
@@ -1382,7 +1381,10 @@ def test_to_list_tailable(self):
13821381
{"ts": {"$gte": ts}}, cursor_type=pymongo.CursorType.TAILABLE_AWAIT, oplog_replay=True
13831382
).max_await_time_ms(1)
13841383
self.addCleanup(c.close)
1385-
docs = c.to_list()
1384+
# Wait for the change to be read.
1385+
docs = []
1386+
while not docs:
1387+
docs = c.to_list()
13861388
self.assertGreaterEqual(len(docs), 1)
13871389

13881390
def test_to_list_empty(self):

0 commit comments

Comments
 (0)