Skip to content

Commit bc494b0

Browse files
committed
Serialize log testing.
1 parent ac88891 commit bc494b0

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,15 @@ jobs:
8484
run: |
8585
uv run ruff check .
8686
87-
- name: pytest
87+
- name: pytest normal
8888
if: ${{ (matrix.os != 'ubuntu-latest') || (matrix.python != '3.14.0') }}
8989
run: |
90-
uv run pytest
90+
uv run pytest -m "not serial"
91+
92+
- name: pytest logging
93+
if: ${{ (matrix.os != 'ubuntu-latest') || (matrix.python != '3.14.0') }}
94+
run: |
95+
uv run pytest "serial"
9196
9297
- name: pytest coverage
9398
if: ${{ (matrix.os == 'ubuntu-latest') && (matrix.python == '3.14.0') }}

test/global/test_logging.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@
1212
)
1313

1414

15+
@pytest.mark.serial
1516
class TestLogging:
1617
"""Tests of pymodbus logging."""
1718

19+
LOG_FILE = "pymodbus.log"
20+
21+
@classmethod
22+
def teardown_class(cls):
23+
"""Remove test file."""
24+
os.remove(cls.LOG_FILE)
25+
1826
def test_log_dont_call_build_msg(self):
1927
"""Verify that build_msg is not called unnecessary."""
2028
with mock.patch("pymodbus.logging.Log.build_msg") as build_msg_mock:
@@ -48,8 +56,7 @@ def test_log_parms(self, txt, result, params):
4856

4957
def test_apply_logging(self):
5058
"""Test pymodbus_apply_logging_config."""
51-
LOG_FILE = "pymodbus.log"
52-
pymodbus_apply_logging_config("debug", LOG_FILE)
59+
pymodbus_apply_logging_config("debug", self.LOG_FILE)
5360
pymodbus_apply_logging_config("info")
5461
pymodbus_apply_logging_config(logging.NOTSET)
5562
Log.debug("test 1no")
@@ -86,7 +93,6 @@ def test_apply_logging(self):
8693
Log.info("test 5")
8794
Log.info("test 5")
8895
logging.shutdown()
89-
os.remove(LOG_FILE)
9096

9197

9298
def test_apply_build_no(self):

0 commit comments

Comments
 (0)