From dde4a01f35f991fac8ab8cd6da1dcbf4fe51d2cd Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 28 May 2025 20:02:48 +0400 Subject: [PATCH] Stop using event_loop fixture (#2969) It was removed in pytest-asyncio 1.0. (cherry picked from commit 3c9680a5cf0b67a56356bf73173a7d5eabb2e552) --- docs/reference/async.md | 3 +-- test_elasticsearch/test_async/test_transport.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/reference/async.md b/docs/reference/async.md index f205d3807..70e8949d5 100644 --- a/docs/reference/async.md +++ b/docs/reference/async.md @@ -34,8 +34,7 @@ async def main(): ) print(resp) -loop = asyncio.get_event_loop() -loop.run_until_complete(main()) +asyncio.run(main()) ``` All APIs that are available under the sync client are also available under the async client. diff --git a/test_elasticsearch/test_async/test_transport.py b/test_elasticsearch/test_async/test_transport.py index ef52ca85c..cf9b8600a 100644 --- a/test_elasticsearch/test_async/test_transport.py +++ b/test_elasticsearch/test_async/test_transport.py @@ -527,7 +527,8 @@ async def test_sniff_on_node_failure_triggers(self, extra_key, extra_value): assert request_failed_in_error assert len(client.transport.node_pool) == 3 - async def test_sniff_after_n_seconds(self, event_loop): + async def test_sniff_after_n_seconds(self): + event_loop = asyncio.get_running_loop() client = AsyncElasticsearch( # noqa: F821 [NodeConfig("http", "localhost", 9200, _extras={"data": CLUSTER_NODES})], node_class=DummyNode, @@ -579,7 +580,8 @@ async def test_sniffing_disabled_on_elastic_cloud(self, kwargs): == "Sniffing should not be enabled when connecting to Elastic Cloud" ) - async def test_sniff_on_start_close_unlocks_async_calls(self, event_loop): + async def test_sniff_on_start_close_unlocks_async_calls(self): + event_loop = asyncio.get_running_loop() client = AsyncElasticsearch( # noqa: F821 [ NodeConfig(