Skip to content

Commit 251caf9

Browse files
committed
Fix asyncio pytest fixtures
1 parent a68cd59 commit 251caf9

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

test_elasticsearch/test_async/test_server/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@
1818
import asyncio
1919

2020
import pytest
21+
import pytest_asyncio
2122

2223
import elasticsearch
2324
from elasticsearch.helpers.test import CA_CERTS, ELASTICSEARCH_URL
2425

2526
from ...utils import wipe_cluster
2627

27-
pytestmark = pytest.mark.asyncio
2828

29-
30-
@pytest.fixture(scope="function")
29+
@pytest_asyncio.fixture(scope="function")
3130
async def async_client():
3231
client = None
3332
try:

test_elasticsearch/test_async/test_server/test_helpers.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from datetime import datetime, timedelta, timezone
2525

2626
import pytest
27+
import pytest_asyncio
2728
from mock import MagicMock, patch
2829

2930
from elasticsearch import TransportError, helpers
@@ -430,7 +431,7 @@ def __await__(self):
430431
return self().__await__()
431432

432433

433-
@pytest.fixture(scope="function")
434+
@pytest_asyncio.fixture(scope="function")
434435
async def scan_teardown(async_client):
435436
yield
436437
await async_client.clear_scroll(scroll_id="_all")
@@ -852,7 +853,7 @@ async def test_scan_from_keyword_is_aliased(self, async_client, scan_kwargs):
852853
assert "from" not in search_mock.call_args[1]
853854

854855

855-
@pytest.fixture(scope="function")
856+
@pytest_asyncio.fixture(scope="function")
856857
async def reindex_setup(async_client):
857858
bulk = []
858859
for x in range(100):
@@ -930,7 +931,7 @@ async def test_all_documents_get_moved(self, async_client, reindex_setup):
930931
)["_source"]
931932

932933

933-
@pytest.fixture(scope="function")
934+
@pytest_asyncio.fixture(scope="function")
934935
async def parent_reindex_setup(async_client):
935936
body = {
936937
"settings": {"number_of_shards": 1, "number_of_replicas": 0},
@@ -993,7 +994,7 @@ async def test_children_are_reindexed_correctly(
993994
} == q
994995

995996

996-
@pytest.fixture(scope="function")
997+
@pytest_asyncio.fixture(scope="function")
997998
async def reindex_data_stream_setup(async_client):
998999
dt = datetime.now(tz=timezone.utc)
9991000
bulk = []

test_elasticsearch/test_async/test_server/test_mapbox_vector_tile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
import re
2121

2222
import pytest
23+
import pytest_asyncio
2324

2425
from elasticsearch import AsyncElasticsearch, RequestError
2526
from elasticsearch.helpers.test import CA_CERTS, ELASTICSEARCH_URL
2627

2728
pytestmark = pytest.mark.asyncio
2829

2930

30-
@pytest.fixture(scope="function")
31+
@pytest_asyncio.fixture(scope="function")
3132
async def mvt_setup(async_client):
3233
await async_client.indices.create(
3334
index="museums",

0 commit comments

Comments
 (0)