Skip to content

Commit 7a61e92

Browse files
committed
Only include async fixtures when running on python3
1 parent c744c1a commit 7a61e92

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

tests/conftest.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from etcd3.client import Client
2-
from etcd3 import AioClient
32
import pytest
43
from .etcd_cluster import EtcdTestCluster
54

@@ -51,26 +50,6 @@ def _clear():
5150
return _clear
5251

5352

54-
@pytest.fixture
55-
async def aio_client(event_loop, request, etcd_cluster):
56-
"""
57-
init Etcd3Client, close its connection-pool when teardown
58-
"""
59-
60-
c = AioClient(endpoints=etcd_cluster.get_endpoints(),
61-
protocol='https' if etcd_cluster.ssl else 'http')
62-
63-
def teardown():
64-
async def _t():
65-
await c.close()
66-
67-
event_loop.run_until_complete(_t())
68-
event_loop._close()
69-
70-
request.addfinalizer(teardown)
71-
return c
72-
73-
7453
def teardown_auth(etcd_cluster): # pragma: no cover
7554
"""
7655
disable auth, delete all users and roles

tests/test_py3/conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
from etcd3 import AioClient
3+
4+
5+
@pytest.fixture
6+
async def aio_client(event_loop, request, etcd_cluster):
7+
"""
8+
init Etcd3Client, close its connection-pool when teardown
9+
"""
10+
11+
c = AioClient(endpoints=etcd_cluster.get_endpoints(),
12+
protocol='https' if etcd_cluster.ssl else 'http')
13+
14+
def teardown():
15+
async def _t():
16+
await c.close()
17+
18+
event_loop.run_until_complete(_t())
19+
event_loop._close()
20+
21+
request.addfinalizer(teardown)
22+
return c

0 commit comments

Comments
 (0)