diff --git a/test/asynchronous/test_cursor.py b/test/asynchronous/test_cursor.py index 833493ce3..d6d56244f 100644 --- a/test/asynchronous/test_cursor.py +++ b/test/asynchronous/test_cursor.py @@ -1380,7 +1380,6 @@ class TestCursor(AsyncIntegrationTest): self.assertEqual("getMore", started[1].command_name) self.assertNotIn("$readPreference", started[1].command) - @async_client_context.require_version_min(4, 0) @async_client_context.require_replica_set async def test_to_list_tailable(self): oplog = self.client.local.oplog.rs @@ -1391,7 +1390,10 @@ class TestCursor(AsyncIntegrationTest): {"ts": {"$gte": ts}}, cursor_type=pymongo.CursorType.TAILABLE_AWAIT, oplog_replay=True ).max_await_time_ms(1) self.addAsyncCleanup(c.close) - docs = await c.to_list() + # Wait for the change to be read. + docs = [] + while not docs: + docs = await c.to_list() self.assertGreaterEqual(len(docs), 1) async def test_to_list_empty(self): diff --git a/test/test_cursor.py b/test/test_cursor.py index e995bd529..0d6186519 100644 --- a/test/test_cursor.py +++ b/test/test_cursor.py @@ -1371,7 +1371,6 @@ class TestCursor(IntegrationTest): self.assertEqual("getMore", started[1].command_name) self.assertNotIn("$readPreference", started[1].command) - @client_context.require_version_min(4, 0) @client_context.require_replica_set def test_to_list_tailable(self): oplog = self.client.local.oplog.rs @@ -1382,7 +1381,10 @@ class TestCursor(IntegrationTest): {"ts": {"$gte": ts}}, cursor_type=pymongo.CursorType.TAILABLE_AWAIT, oplog_replay=True ).max_await_time_ms(1) self.addCleanup(c.close) - docs = c.to_list() + # Wait for the change to be read. + docs = [] + while not docs: + docs = c.to_list() self.assertGreaterEqual(len(docs), 1) def test_to_list_empty(self):