Print test name at start if the log level is INFO or lower

This commit is contained in:
2025-12-05 16:25:31 +01:00
parent 1ee70bd87d
commit dcc35d08c6

View File

@@ -3,6 +3,7 @@ import logging
from caproto.sync.client import read
import pytest
from pytest import TestReport
from src.classes import read_config, IocNotRunning
@@ -89,3 +90,16 @@ def configure_motor_logging(request):
logger = logging.getLogger("motor")
logger.handlers.clear()
logger.setLevel(level)
# Level of the pytest logger
logger = logging.getLogger("pytest")
logger.setLevel(level)
def pytest_runtest_logreport(report: TestReport):
"""
Print the start of a test if the log level of the motor is INFO or lower.
"""
loglevel = logging.getLogger("pytest").getEffectiveLevel()
if loglevel <= logging.INFO and report.when == 'call':
print(f"Running test: {report.nodeid}")