Skip to content

Commit 19c4d34

Browse files
committed
Add tests that quoted local parts are unquoted in the returned normalized address where possible
1 parent 306948d commit 19c4d34

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ necessarily for composing an email message, see below).
1212

1313
Key features:
1414

15-
* Checks that an email address has the correct syntax --- good for
16-
registration/login forms or other uses related to identifying users.
15+
* Checks that an email address has the correct syntax --- great for
16+
email-based registration/login forms or validing data.
1717
* Gives friendly English error messages when validation fails that you
1818
can display to end-users.
1919
* Checks deliverability (optional): Does the domain name resolve?

tests/test_syntax.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,41 @@
6868
ascii_email='jeff@xn--fiqq24b10vi0d.tw',
6969
),
7070
),
71+
(
72+
'"quoted local part"@example.org',
73+
ValidatedEmail(
74+
local_part='"quoted local part"',
75+
ascii_local_part='"quoted local part"',
76+
smtputf8=False,
77+
ascii_domain='example.org',
78+
domain='example.org',
79+
normalized='"quoted local part"@example.org',
80+
ascii_email='"quoted local part"@example.org'
81+
),
82+
),
83+
(
84+
'"de-quoted.local.part"@example.org',
85+
ValidatedEmail(
86+
local_part='de-quoted.local.part',
87+
ascii_local_part='de-quoted.local.part',
88+
smtputf8=False,
89+
ascii_domain='example.org',
90+
domain='example.org',
91+
normalized='de-quoted.local.part@example.org',
92+
ascii_email='de-quoted.local.part@example.org'
93+
),
94+
),
7195
],
7296
)
7397
def test_email_valid(email_input, output):
7498
# These addresses do not require SMTPUTF8. See test_email_valid_intl_local_part
7599
# for addresses that are valid but require SMTPUTF8. Check that it passes with
76100
# allow_smtput8 both on and off.
77-
emailinfo = validate_email(email_input, check_deliverability=False, allow_smtputf8=False)
101+
emailinfo = validate_email(email_input, check_deliverability=False, allow_smtputf8=False,
102+
allow_quoted_local=True)
78103
assert emailinfo == output
79-
assert validate_email(email_input, check_deliverability=False, allow_smtputf8=True) == output
104+
assert validate_email(email_input, check_deliverability=False, allow_smtputf8=True,
105+
allow_quoted_local=True) == output
80106

81107
# Check that the old `email` attribute to access the normalized form still works
82108
# if the DeprecationWarning is suppressed.

0 commit comments

Comments
 (0)