Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pymodbus/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def build_msg(cls, txt, *args):
if not cls.repeat_log:
cls.repeat_log = True
return "Repeating...."
return cls.last_log_text
return None

@classmethod
def info(cls, txt, *args):
Expand Down
11 changes: 10 additions & 1 deletion test/global/test_logging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test datastore."""
import contextlib
import logging
import os
from unittest import mock
Expand All @@ -21,7 +22,8 @@ class TestLogging:
def teardown_class(cls):
"""Remove test file."""
if "CI" not in os.environ: # pragma: no cover
os.remove(cls.LOG_FILE)
with contextlib.suppress(FileNotFoundError):
os.remove(cls.LOG_FILE)

def test_log_dont_call_build_msg(self):
"""Verify that build_msg is not called unnecessary."""
Expand Down Expand Up @@ -117,6 +119,13 @@ def test_log_get_frames(self):
Log.transport_dump(Log.SEND_DATA, b'678', b'9')
pymodbus_get_last_frames()

def test_log_repeat(self):
"""Test repeating log Frames."""
text = "msg being repeated."
assert text == Log.build_msg(text)
assert Log.build_msg(text) == "Repeating...."
assert not Log.build_msg(text)

def test_transport_dump(self):
"""Test transport_dump."""
pymodbus_apply_logging_config("error")
Expand Down
Loading