37
37
from elasticsearch .exceptions import ConnectionError
38
38
from elasticsearch .helpers import bulk
39
39
40
- from ..utils import CA_CERTS
40
+ from ..utils import CA_CERTS , wipe_cluster
41
41
from .test_integration ._async import test_document as async_document
42
42
from .test_integration ._sync import test_document as sync_document
43
43
from .test_integration .test_data import (
@@ -110,14 +110,16 @@ def _get_version(version_string: str) -> Tuple[int, ...]:
110
110
return tuple (int (v ) if v .isdigit () else 999 for v in version )
111
111
112
112
113
- @fixture ( scope = "session" )
113
+ @fixture
114
114
def client (elasticsearch_url ) -> Elasticsearch :
115
115
try :
116
116
connection = get_test_client (
117
117
elasticsearch_url , wait = "WAIT_FOR_ES" in os .environ
118
118
)
119
119
add_connection ("default" , connection )
120
- return connection
120
+ yield connection
121
+ wipe_cluster (connection )
122
+ connection .close ()
121
123
except SkipTest :
122
124
skip ()
123
125
@@ -130,12 +132,13 @@ async def async_client(elasticsearch_url) -> AsyncGenerator[AsyncElasticsearch,
130
132
)
131
133
add_async_connection ("default" , connection )
132
134
yield connection
135
+ wipe_cluster (connection )
133
136
await connection .close ()
134
137
except SkipTest :
135
138
skip ()
136
139
137
140
138
- @fixture ( scope = "session" )
141
+ @fixture
139
142
def es_version (client : Elasticsearch ) -> Generator [Tuple [int , ...], None , None ]:
140
143
info = client .info ()
141
144
yield tuple (
@@ -192,7 +195,7 @@ def async_mock_client(
192
195
async_connections ._kwargs = {}
193
196
194
197
195
- @fixture ( scope = "session" )
198
+ @fixture
196
199
def data_client (client : Elasticsearch ) -> Generator [Elasticsearch , None , None ]:
197
200
# create mappings
198
201
create_git_index (client , "git" )
0 commit comments