From ac4744e115c7387044c676d0d807ef17db353b7d Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Sat, 7 Feb 2026 23:20:03 -0300 Subject: [PATCH 1/2] refactor: use pytest.mark.parametrize for ip4scout tests Each ip4scout file is now a distinct test case, making zero files visible in output instead of silently passing. Also sort the file list for deterministic ordering and simplify Path method calls. Closes #32 --- tests/test_l9format.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/test_l9format.py b/tests/test_l9format.py index 573e848..ac86296 100644 --- a/tests/test_l9format.py +++ b/tests/test_l9format.py @@ -1,15 +1,15 @@ import json from pathlib import Path +import pytest + from l9format import L9Event TESTS_DIR = Path(__file__).parent -IP4SCOUT_FILES = [ - f - for f in Path.iterdir(TESTS_DIR) - if Path.is_file(f) and "ip4scout" in f.name -] +IP4SCOUT_FILES = sorted( + f for f in TESTS_DIR.iterdir() if f.is_file() and "ip4scout" in f.name +) def test_l9event_json_from_reference_repository() -> None: @@ -55,17 +55,17 @@ def test_l9event_json_from_reference_repository() -> None: ] -def test_l9events_from_ip4scout() -> None: - for path in IP4SCOUT_FILES: - with open(path) as f: - c = json.load(f) - event = L9Event.from_dict(c) - assert event.event_source == "ip4scout" - assert event.event_type == "synack" - assert isinstance(event.ip, str) - assert len(event.ip) > 0 - assert isinstance(event.port, str) - assert len(event.port) > 0 +@pytest.mark.parametrize("path", IP4SCOUT_FILES, ids=lambda p: p.name) +def test_l9events_from_ip4scout(path: Path) -> None: + with open(path) as f: + c = json.load(f) + event = L9Event.from_dict(c) + assert event.event_source == "ip4scout" + assert event.event_type == "synack" + assert isinstance(event.ip, str) + assert len(event.ip) > 0 + assert isinstance(event.port, str) + assert len(event.port) > 0 def test_iso8601_nanosecond_parsing() -> None: From 398fbe1281bcc713a940c9554fa59460e7601d33 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Sat, 7 Feb 2026 23:21:22 -0300 Subject: [PATCH 2/2] CHANGELOG: parametrize ip4scout tests (#32) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47cdab..1d0d2d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ and this project adheres to ([1dcfbef], [#21]) - Tests now import from `l9format` package directly instead of `l9format.l9format` ([e8aef2e], [#21]) +- Use `pytest.mark.parametrize` for ip4scout tests so each file is a distinct + test case ([ac4744e], [#32]) ### Fixed @@ -160,6 +162,7 @@ and this project adheres to +[ac4744e]: https://github.com/LeakIX/l9format-python/commit/ac4744e [d554f1e]: https://github.com/LeakIX/l9format-python/commit/d554f1e [7f49ff5]: https://github.com/LeakIX/l9format-python/commit/7f49ff5 [cd74b55]: https://github.com/LeakIX/l9format-python/commit/cd74b55 @@ -241,4 +244,5 @@ and this project adheres to [#35]: https://github.com/LeakIX/l9format-python/issues/35 [#24]: https://github.com/LeakIX/l9format-python/issues/24 [#31]: https://github.com/LeakIX/l9format-python/issues/31 +[#32]: https://github.com/LeakIX/l9format-python/issues/32 [#43]: https://github.com/LeakIX/l9format-python/issues/43