From 7a3f632b4906d4cc06f1eabd1f54b42378ebfb99 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Wed, 13 Mar 2024 18:18:42 +0100 Subject: [PATCH] Move conftest log initialization to conftest.py Initializing the conftest logging upon importing the isctest package isn't practical when there are standalone pieces which can be used outside of the testing framework, such as the asyncdnsserver module. (cherry picked from commit 673387c4d515ecd1dd5dd6d854e629907b914970) --- bin/tests/system/conftest.py | 3 +++ bin/tests/system/isctest/log/__init__.py | 2 ++ bin/tests/system/isctest/log/basic.py | 4 ---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 2f84bb108b..ee792fb0a8 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -33,6 +33,9 @@ import isctest if sys.version_info[1] < 10: raise RuntimeError("Python 3.10 or newer is required to run system tests.") +isctest.log.init_conftest_logger() +isctest.log.avoid_duplicated_logs() + # ----------------------- Globals definition ----------------------------- XDIST_WORKER = os.environ.get("PYTEST_XDIST_WORKER", "") diff --git a/bin/tests/system/isctest/log/__init__.py b/bin/tests/system/isctest/log/__init__.py index 702a9562d0..228f69e5bf 100644 --- a/bin/tests/system/isctest/log/__init__.py +++ b/bin/tests/system/isctest/log/__init__.py @@ -10,8 +10,10 @@ # information regarding copyright ownership. from .basic import ( + avoid_duplicated_logs, deinit_module_logger, deinit_test_logger, + init_conftest_logger, init_module_logger, init_test_logger, debug, diff --git a/bin/tests/system/isctest/log/basic.py b/bin/tests/system/isctest/log/basic.py index 41b5ee68a1..41988e9cbc 100644 --- a/bin/tests/system/isctest/log/basic.py +++ b/bin/tests/system/isctest/log/basic.py @@ -54,10 +54,6 @@ def avoid_duplicated_logs(): logging.root.handlers.remove(handler) -init_conftest_logger() -avoid_duplicated_logs() - - def init_module_logger(system_test_name: str, testdir: Path): logger = logging.getLogger(system_test_name) logger.handlers.clear()