From dcc35d08c62feb020e7c3e58c0008e563667ba66 Mon Sep 17 00:00:00 2001 From: smathis Date: Fri, 5 Dec 2025 16:25:31 +0100 Subject: [PATCH] Print test name at start if the log level is INFO or lower --- tests/conftest.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index fed44f3..fdfd4bd 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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}")