Skip to content

Commit

Permalink
Fix asyncio pytest fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Oct 30, 2023
1 parent 376d8e3 commit e1d81b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 2 additions & 3 deletions test_elasticsearch/test_async/test_server/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
import asyncio

import pytest
import pytest_asyncio

import elasticsearch
from elasticsearch.helpers.test import CA_CERTS, ELASTICSEARCH_URL

from ...utils import wipe_cluster

pytestmark = pytest.mark.asyncio


@pytest.fixture(scope="function")
@pytest_asyncio.fixture(scope="function")
async def async_client():
client = None
try:
Expand Down
9 changes: 5 additions & 4 deletions test_elasticsearch/test_async/test_server/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from datetime import datetime, timedelta, timezone

import pytest
import pytest_asyncio
from mock import MagicMock, patch

from elasticsearch import TransportError, helpers
Expand Down Expand Up @@ -430,7 +431,7 @@ def __await__(self):
return self().__await__()


@pytest.fixture(scope="function")
@pytest_asyncio.fixture(scope="function")
async def scan_teardown(async_client):
yield
await async_client.clear_scroll(scroll_id="_all")
Expand Down Expand Up @@ -852,7 +853,7 @@ async def test_scan_from_keyword_is_aliased(self, async_client, scan_kwargs):
assert "from" not in search_mock.call_args[1]


@pytest.fixture(scope="function")
@pytest_asyncio.fixture(scope="function")
async def reindex_setup(async_client):
bulk = []
for x in range(100):
Expand Down Expand Up @@ -930,7 +931,7 @@ async def test_all_documents_get_moved(self, async_client, reindex_setup):
)["_source"]


@pytest.fixture(scope="function")
@pytest_asyncio.fixture(scope="function")
async def parent_reindex_setup(async_client):
body = {
"settings": {"number_of_shards": 1, "number_of_replicas": 0},
Expand Down Expand Up @@ -993,7 +994,7 @@ async def test_children_are_reindexed_correctly(
} == q


@pytest.fixture(scope="function")
@pytest_asyncio.fixture(scope="function")
async def reindex_data_stream_setup(async_client):
dt = datetime.now(tz=timezone.utc)
bulk = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
import re

import pytest
import pytest_asyncio

from elasticsearch import AsyncElasticsearch, RequestError
from elasticsearch.helpers.test import CA_CERTS, ELASTICSEARCH_URL

pytestmark = pytest.mark.asyncio


@pytest.fixture(scope="function")
@pytest_asyncio.fixture(scope="function")
async def mvt_setup(async_client):
await async_client.indices.create(
index="museums",
Expand Down

0 comments on commit e1d81b5

Please sign in to comment.