diff --git a/tests/conftest.py b/tests/conftest.py index 503071a1..75c8a92d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ from contextlib import asynccontextmanager as acm +from functools import partial import os import pytest @@ -19,6 +20,11 @@ def pytest_addoption(parser): help="Use a practice API account") +@pytest.fixture(scope='session') +def loglevel(request) -> str: + return request.config.option.loglevel + + @pytest.fixture(scope='session') def test_config(): dirname = os.path.dirname @@ -32,7 +38,10 @@ def test_config(): @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 broker config file found in that dir. @@ -84,6 +93,7 @@ async def _open_test_pikerd( async with ( maybe_open_pikerd( registry_addr=reg_addr, + loglevel=loglevel, **kwargs, ) as service_manager, ): @@ -105,9 +115,18 @@ async def _open_test_pikerd( @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 ` cli flag. + loglevel=loglevel, + ) # TODO: teardown checks such as, # - no leaked subprocs or shm buffers diff --git a/tests/test_feeds.py b/tests/test_feeds.py index 2b85301f..a79ca861 100644 --- a/tests/test_feeds.py +++ b/tests/test_feeds.py @@ -35,6 +35,7 @@ from piker.data._source import ( def test_multi_fqsn_feed( open_test_pikerd: AsyncContextManager, fqsns: set[str], + loglevel: str, ci_env: bool ): ''' @@ -60,7 +61,7 @@ def test_multi_fqsn_feed( open_test_pikerd(), open_feed( fqsns, - loglevel='info', + loglevel=loglevel, # TODO: ensure throttle rate is applied # limit to at least display's FPS