Skip to content

Commit 7c5d340

Browse files
committed
added edge cases on test suite
1 parent 6ffd862 commit 7c5d340

5 files changed

Lines changed: 43 additions & 0 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""HU-02: reject SOH in an address intended for SMTP (RFC 5321)."""
2+
import validators
3+
4+
5+
def test_email_rejects_soh_control_character():
6+
# The Python escape introduces the actual ASCII SOH character.
7+
email = '"user\x01name"@example.com'
8+
result = validators.email(email)
9+
assert isinstance(result, validators.ValidationError), repr(result)

‎tests/test_email_ipv6_literal.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""HU-02: accept the IPv6: prefix in an SMTP address literal."""
2+
import validators
3+
4+
5+
def test_email_accepts_ipv6_literal_with_prefix():
6+
result = validators.email(
7+
"usuario@[IPv6:2001:db8::1]", ipv6_address=True
8+
)
9+
assert result is True, repr(result)

‎tests/test_email_quoted_at_sign.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""HU-02: accept @ inside a quoted local part."""
2+
import validators
3+
4+
5+
def test_email_accepts_at_sign_inside_quoted_local_part():
6+
result = validators.email('"user@name"@example.com')
7+
assert result is True, repr(result)

‎tests/test_ipv4_strict_cidr.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""HU-04: require a prefix length in the documented strict CIDR mode."""
2+
import validators
3+
4+
5+
def test_ipv4_strict_cidr_rejects_dotted_netmask():
6+
# The network is valid, but its representation is not CIDR prefix notation.
7+
result = validators.ipv4("192.168.1.0/255.255.255.0", strict=True)
8+
assert isinstance(result, validators.ValidationError), repr(result)

‎tests/test_ipv6_brackets.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""HU-04: proposed enhancement; brackets are URL host syntax.
2+
3+
This test expresses a new requirement, not a defect in the current contract.
4+
"""
5+
import validators
6+
7+
8+
def test_ipv6_accepts_address_in_brackets():
9+
result = validators.ipv6("[2001:db8::1]")
10+
assert result is True, repr(result)

0 commit comments

Comments
 (0)