diff --git a/test/global/test_logging.py b/test/global/test_logging.py index cde2198a2..c4d0d7da4 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 "CI" not 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):