Skip to content

Commit a77ed6f

Browse files
committed
added docstrings on 5 tests
1 parent 7c5d340 commit a77ed6f

5 files changed

Lines changed: 64 additions & 12 deletions
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
"""HU-02: reject SOH in an address intended for SMTP (RFC 5321)."""
2+
3+
# external
4+
import pytest
5+
26
import validators
37

48

5-
def test_email_rejects_soh_control_character():
6-
# The Python escape introduces the actual ASCII SOH character.
7-
email = '"user\x01name"@example.com'
9+
@pytest.mark.parametrize(
10+
("email",),
11+
[
12+
('"user\x01name"@example.com', ),
13+
],
14+
)
15+
def test_email_rejects_soh_control_character(email: str):
16+
"""The Python escape introduces the actual ASCII SOH character."""
817
result = validators.email(email)
918
assert isinstance(result, validators.ValidationError), repr(result)

‎tests/test_email_ipv6_literal.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
"""HU-02: accept the IPv6: prefix in an SMTP address literal."""
2+
3+
# external
4+
import pytest
5+
26
import validators
37

48

5-
def test_email_accepts_ipv6_literal_with_prefix():
9+
@pytest.mark.parametrize(
10+
("email",),
11+
[
12+
("usuario@[IPv6:2001:db8::1]", ),
13+
],
14+
)
15+
def test_email_accepts_ipv6_literal_with_prefix(email: str):
16+
"""Email accepts ipv6 literal with prefix."""
617
result = validators.email(
7-
"usuario@[IPv6:2001:db8::1]", ipv6_address=True
18+
email, ipv6_address=True
819
)
920
assert result is True, repr(result)

‎tests/test_email_quoted_at_sign.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
"""HU-02: accept @ inside a quoted local part."""
2+
3+
# external
4+
import pytest
5+
26
import validators
37

48

5-
def test_email_accepts_at_sign_inside_quoted_local_part():
6-
result = validators.email('"user@name"@example.com')
9+
@pytest.mark.parametrize(
10+
("email",),
11+
[
12+
('"user@name"@example.com', ),
13+
],
14+
)
15+
def test_email_accepts_at_sign_inside_quoted_local_part(email: str):
16+
"""The email accepts at sign inside quoted local part character."""
17+
result = validators.email(email)
718
assert result is True, repr(result)

‎tests/test_ipv4_strict_cidr.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
"""HU-04: require a prefix length in the documented strict CIDR mode."""
2+
3+
# external
4+
import pytest
5+
26
import validators
37

48

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)
9+
@pytest.mark.parametrize(
10+
("ip",),
11+
[
12+
("192.168.1.0/255.255.255.0", ),
13+
],
14+
)
15+
def test_ipv4_strict_cidr_rejects_dotted_netmask(ip: str):
16+
"""The network is valid, but its representation is not CIDR prefix notation."""
17+
result = validators.ipv4(ip, strict=True)
818
assert isinstance(result, validators.ValidationError), repr(result)

‎tests/test_ipv6_brackets.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22
33
This test expresses a new requirement, not a defect in the current contract.
44
"""
5+
6+
# external
7+
import pytest
8+
59
import validators
610

711

8-
def test_ipv6_accepts_address_in_brackets():
9-
result = validators.ipv6("[2001:db8::1]")
12+
@pytest.mark.parametrize(
13+
("ip",),
14+
[
15+
("[2001:db8::1]", ),
16+
],
17+
)
18+
def test_ipv6_accepts_address_in_brackets(ip: str):
19+
"""Accept iv6 address in brackets."""
20+
result = validators.ipv6(ip)
1021
assert result is True, repr(result)

0 commit comments

Comments
 (0)