Skip to content

Commit

Permalink
set asyncio_mode to auto and reduce boilerplate code
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-be committed May 7, 2024
1 parent 4a3205a commit ea99d81
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions aiozk/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from aiozk import ZKClient, exc # noqa
from aiozk.states import States
import pytest
import pytest_asyncio


HOST = os.environ.get('ZK_HOST', 'zk')
Expand Down Expand Up @@ -42,7 +41,7 @@ def path():
yield f'/{uuid.uuid4().hex}'


@pytest_asyncio.fixture
@pytest.fixture
async def zk():
c = get_client()
await c.start()
Expand All @@ -59,7 +58,7 @@ async def zk():
await c.close()


@pytest_asyncio.fixture
@pytest.fixture
async def zk2():
c = get_client()
await c.start()
Expand Down
3 changes: 1 addition & 2 deletions aiozk/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
import uuid
import pytest
import pytest_asyncio

from aiozk import WatchEvent
from .conftest import get_client
Expand All @@ -11,7 +10,7 @@
logging.getLogger('asyncio').setLevel(logging.DEBUG)


@pytest_asyncio.fixture
@pytest.fixture
async def full_zk(zk, path):
child_1 = f'{path}/{uuid.uuid4().hex}'
child_2 = f'{path}/{uuid.uuid4().hex}'
Expand Down
5 changes: 2 additions & 3 deletions aiozk/test/test_treecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import uuid

import pytest
import pytest_asyncio


class Tree:
Expand Down Expand Up @@ -36,15 +35,15 @@ async def modify(self):
await asyncio.sleep(0.1)


@pytest_asyncio.fixture
@pytest.fixture
async def tree(zk, path):
out = Tree(zk, path)
await out.init()
yield out
await zk.deleteall(path)


@pytest_asyncio.fixture
@pytest.fixture
async def tree_cache(zk, path):
cache = zk.recipes.TreeCache(path)
cache.set_client(zk)
Expand Down
5 changes: 2 additions & 3 deletions aiozk/test/test_watchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import uuid

import pytest
import pytest_asyncio

from .. import WatchEvent
from ..exc import NoNode
from ..recipes.data_watcher import DataWatcher


@pytest_asyncio.fixture
@pytest.fixture
async def data_watcher(zk, path):
await zk.create(path)
watcher = zk.recipes.DataWatcher()
Expand Down Expand Up @@ -88,7 +87,7 @@ def child2(path):
yield f'{path}/{uuid.uuid4().hex}'


@pytest_asyncio.fixture
@pytest.fixture
async def child_watcher(zk, path, child1, child2):
await zk.create(path)
watcher = zk.recipes.ChildrenWatcher()
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[pytest]
addopts = --cov=aiozk --cov-config=.coveragerc
asyncio_mode = auto

0 comments on commit ea99d81

Please sign in to comment.