1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
import asyncio
import os
import pytest
from postfix_mta_sts_resolver.utils import enable_uvloop, create_cache, populate_cfg_defaults
@pytest.fixture(scope="session")
def event_loop():
uvloop_test = os.environ['TOXENV'].endswith('-uvloop')
uvloop_enabled = enable_uvloop()
assert uvloop_test == uvloop_enabled
loop = asyncio.get_event_loop()
yield loop
loop.close()
@pytest.fixture(scope="function")
async def function_cache_fixture():
cfg = populate_cfg_defaults(None)
cache = create_cache(cfg['cache']['type'],
cfg['cache']['options'])
await cache.setup()
yield cache
await cache.teardown()
@pytest.fixture(scope="module")
async def module_cache_fixture():
cfg = populate_cfg_defaults(None)
cache = create_cache(cfg['cache']['type'],
cfg['cache']['options'])
await cache.setup()
yield cache
await cache.teardown()
|