Add `log` fixture for easy test plugin

service_subpkg
Tyler Goodlet 2023-03-09 17:57:42 -05:00
parent 7cc9911565
commit 9a00c45923
1 changed files with 17 additions and 0 deletions

View File

@ -1,5 +1,6 @@
from contextlib import asynccontextmanager as acm
from functools import partial
import logging
import os
from pathlib import Path
@ -11,6 +12,7 @@ from piker import (
from piker.service import (
Services,
)
from piker.log import get_console_log
from piker.clearing._client import open_ems
@ -67,6 +69,21 @@ def ci_env() -> bool:
return _ci_env
@pytest.fixture()
def log(
request: pytest.FixtureRequest,
loglevel: str,
) -> logging.Logger:
'''
Deliver a per-test-named ``piker.log`` instance.
'''
return get_console_log(
level=loglevel,
name=request.node.name,
)
@acm
async def _open_test_pikerd(
tmpconfdir: str,