Files
lix/tests/functional2/testlib/fixtures/logger.py
T
Commentator2.0 01985e5add functional2: use loggers
Use logger in favor over print statment.
This is explicitly supported and encuraged by pytest, which also allows
for capturing logs separate from stdout calls, which is handy for when
e.g. lix code calls out to stdout to keep those differentiated from test
output

Change-Id: Ib88565a1663da3b77ca6b95f8edf644eafb4a99d
2025-05-10 21:13:45 +02:00

16 lines
414 B
Python

import logging
from logging import Logger
import pytest
from _pytest.fixtures import FixtureRequest
@pytest.fixture
def logger(request: FixtureRequest) -> Logger:
"""
Returns a logger object to use in a test function.
:param request: provide by pytest, information about where this fixture was used
:return: a logger object to use
"""
return logging.getLogger(request.function.__name__)