From 34df32ac68b61c94df88e193d108c812a83c90ff Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2026 03:54:19 +0000 Subject: [PATCH] Add parameterized tests for _looks_like_ip Add test coverage for the deterministic `_looks_like_ip` function in `netsleuth/netinfo.py`. The added tests cover valid IPv4, valid IPv6, invalid strings, and edge cases to ensure the parsing behavior works as expected and fails gracefully on bad input. Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> --- tests/test_netinfo.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_netinfo.py b/tests/test_netinfo.py index 7134cd9..2fb3614 100644 --- a/tests/test_netinfo.py +++ b/tests/test_netinfo.py @@ -334,3 +334,26 @@ def test_collect_local_net_no_network(mock_resolvers, mock_gw, mock_stats, mock_ assert result.default_gateway_v6 is None assert result.is_dual_stack is False assert result.cgnat is False + + +from netsleuth.netinfo import _looks_like_ip + +@pytest.mark.parametrize( + ("token", "expected"), + [ + ("192.168.1.1", True), + ("8.8.8.8", True), + ("255.255.255.255", True), + ("0.0.0.0", True), + ("2001:db8::1", True), + ("::1", True), + ("fe80::1ff:fe23:4567:890a", True), + ("not_an_ip", False), + ("256.256.256.256", False), + ("192.168.1", False), + ("2001:db8:::1", False), + ("", False), + ] +) +def test_looks_like_ip(token, expected): + assert _looks_like_ip(token) is expected