From cceab1df1e658a74a31d6e7097f890aa927664d4 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sat, 4 Oct 2025 18:49:38 +0000 Subject: [PATCH 1/2] Avoid windows problem with log testing.. --- test/global/test_logging.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/global/test_logging.py b/test/global/test_logging.py index cde2198a2..dd8f31ea6 100644 --- a/test/global/test_logging.py +++ b/test/global/test_logging.py @@ -15,6 +15,14 @@ class TestLogging: """Tests of pymodbus logging.""" + LOG_FILE = "pymodbus.log" + + @classmethod + def teardown_class(cls): + """Remove test file.""" + if not "CI" in os.environ: + os.remove(cls.LOG_FILE) + def test_log_dont_call_build_msg(self): """Verify that build_msg is not called unnecessary.""" with mock.patch("pymodbus.logging.Log.build_msg") as build_msg_mock: @@ -48,8 +56,7 @@ def test_log_parms(self, txt, result, params): def test_apply_logging(self): """Test pymodbus_apply_logging_config.""" - LOG_FILE = "pymodbus.log" - pymodbus_apply_logging_config("debug", LOG_FILE) + pymodbus_apply_logging_config("debug", self.LOG_FILE) pymodbus_apply_logging_config("info") pymodbus_apply_logging_config(logging.NOTSET) Log.debug("test 1no") @@ -86,7 +93,6 @@ def test_apply_logging(self): Log.info("test 5") Log.info("test 5") logging.shutdown() - os.remove(LOG_FILE) def test_apply_build_no(self): From 787576b5920de55f4e23f801ff897081a18ed6d4 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sun, 5 Oct 2025 07:32:28 +0000 Subject: [PATCH 2/2] CI --- test/global/test_logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/global/test_logging.py b/test/global/test_logging.py index dd8f31ea6..c4d0d7da4 100644 --- a/test/global/test_logging.py +++ b/test/global/test_logging.py @@ -20,7 +20,7 @@ class TestLogging: @classmethod def teardown_class(cls): """Remove test file.""" - if not "CI" in os.environ: + if "CI" not in os.environ: os.remove(cls.LOG_FILE) def test_log_dont_call_build_msg(self):