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
16 lines
414 B
Python
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__)
|