Skip to content

Commit

Permalink
Add test_looks_like_ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotwutingfeng committed Feb 22, 2024
1 parent d42beec commit a23d29a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import tldextract
import tldextract.suffix_list
from tldextract.cache import DiskCache
from tldextract.remote import lenient_netloc, looks_like_ip
from tldextract.remote import lenient_netloc, looks_like_ip, looks_like_ipv6
from tldextract.suffix_list import SuffixListNotFound
from tldextract.tldextract import ExtractResult

Expand Down Expand Up @@ -161,6 +161,16 @@ def test_looks_like_ip() -> None:
assert looks_like_ip("256.256.256.256") is False


def test_looks_like_ipv6() -> None:
"""Test function to check if a string looks like an IPv6 address."""
assert looks_like_ipv6("::") is True
assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:aaaa:2288") is True
assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is True
assert looks_like_ipv6("ZBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1") is False
assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.01") is False
assert looks_like_ipv6("aBcD:ef01:2345:6789:aBcD:") is False


def test_similar_to_ip() -> None:
"""Test strings that look like IP addresses but are not."""
assert_extract("1\xe9", ("", "", "1\xe9", ""))
Expand Down

0 comments on commit a23d29a

Please sign in to comment.