Skip to content

Commit

Permalink
Add loglevel: str fixture, passthrough to open_test_pikerd()
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Feb 21, 2023
1 parent bca4814 commit 5223eb1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
25 changes: 22 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from contextlib import asynccontextmanager as acm
from functools import partial
import os

import pytest
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -84,6 +93,7 @@ async def _open_test_pikerd(
async with (
maybe_open_pikerd(
registry_addr=reg_addr,
loglevel=loglevel,
**kwargs,
) as service_manager,
):
Expand All @@ -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 <value>` cli flag.
loglevel=loglevel,
)

# TODO: teardown checks such as,
# - no leaked subprocs or shm buffers
Expand Down
3 changes: 2 additions & 1 deletion tests/test_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
def test_multi_fqsn_feed(
open_test_pikerd: AsyncContextManager,
fqsns: set[str],
loglevel: str,
ci_env: bool
):
'''
Expand All @@ -60,7 +61,7 @@ async def main():
open_test_pikerd(),
open_feed(
fqsns,
loglevel='info',
loglevel=loglevel,

# TODO: ensure throttle rate is applied
# limit to at least display's FPS
Expand Down

0 comments on commit 5223eb1

Please sign in to comment.