Add `loglevel: str` fixture, passthrough to `open_test_pikerd()`

loglevel_to_testpikerd
Tyler Goodlet 2023-02-21 10:21:03 -05:00
parent 2bad692703
commit b3400f0d9c
2 changed files with 24 additions and 4 deletions

View File

@ -1,4 +1,5 @@
from contextlib import asynccontextmanager as acm from contextlib import asynccontextmanager as acm
from functools import partial
import os import os
import pytest import pytest
@ -19,6 +20,11 @@ def pytest_addoption(parser):
help="Use a practice API account") help="Use a practice API account")
@pytest.fixture(scope='session')
def loglevel(request) -> str:
return request.config.option.loglevel
@pytest.fixture(scope='session') @pytest.fixture(scope='session')
def test_config(): def test_config():
dirname = os.path.dirname dirname = os.path.dirname
@ -32,7 +38,10 @@ def test_config():
@pytest.fixture(scope='session', autouse=True) @pytest.fixture(scope='session', autouse=True)
def confdir(request, test_config): def confdir(
request,
test_config: str,
):
''' '''
If the `--confdir` flag is not passed use the If the `--confdir` flag is not passed use the
broker config file found in that dir. broker config file found in that dir.
@ -84,6 +93,7 @@ async def _open_test_pikerd(
async with ( async with (
maybe_open_pikerd( maybe_open_pikerd(
registry_addr=reg_addr, registry_addr=reg_addr,
loglevel=loglevel,
**kwargs, **kwargs,
) as service_manager, ) as service_manager,
): ):
@ -105,9 +115,18 @@ async def _open_test_pikerd(
@pytest.fixture @pytest.fixture
def open_test_pikerd(request): def open_test_pikerd(
request,
loglevel: str,
):
yield _open_test_pikerd yield partial(
_open_test_pikerd,
# bind in level from fixture, which is itself set by
# `--ll <value>` cli flag.
loglevel=loglevel,
)
# TODO: teardown checks such as, # TODO: teardown checks such as,
# - no leaked subprocs or shm buffers # - no leaked subprocs or shm buffers

View File

@ -35,6 +35,7 @@ from piker.data._source import (
def test_multi_fqsn_feed( def test_multi_fqsn_feed(
open_test_pikerd: AsyncContextManager, open_test_pikerd: AsyncContextManager,
fqsns: set[str], fqsns: set[str],
loglevel: str,
ci_env: bool ci_env: bool
): ):
''' '''
@ -60,7 +61,7 @@ def test_multi_fqsn_feed(
open_test_pikerd(), open_test_pikerd(),
open_feed( open_feed(
fqsns, fqsns,
loglevel='info', loglevel=loglevel,
# TODO: ensure throttle rate is applied # TODO: ensure throttle rate is applied
# limit to at least display's FPS # limit to at least display's FPS