Skip to content

Commit

Permalink
Add tests that quoted local parts are unquoted in the returned normal…
Browse files Browse the repository at this point in the history
…ized address where possible
  • Loading branch information
JoshData committed Feb 12, 2024
1 parent 306948d commit 4161071
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ necessarily for composing an email message, see below).

Key features:

* Checks that an email address has the correct syntax --- good for
registration/login forms or other uses related to identifying users.
* Checks that an email address has the correct syntax --- great for
email-based registration/login forms or validing data.
* Gives friendly English error messages when validation fails that you
can display to end-users.
* Checks deliverability (optional): Does the domain name resolve?
Expand Down
30 changes: 28 additions & 2 deletions tests/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,41 @@
ascii_email='[email protected]',
),
),
(
'"quoted local part"@example.org',
ValidatedEmail(
local_part='"quoted local part"',
ascii_local_part='"quoted local part"',
smtputf8=False,
ascii_domain='example.org',
domain='example.org',
normalized='"quoted local part"@example.org',
ascii_email='"quoted local part"@example.org'
),
),
(
'"de-quoted.local.part"@example.org',
ValidatedEmail(
local_part='de-quoted.local.part',
ascii_local_part='de-quoted.local.part',
smtputf8=False,
ascii_domain='example.org',
domain='example.org',
normalized='[email protected]',
ascii_email='[email protected]'
),
),
],
)
def test_email_valid(email_input, output):
# These addresses do not require SMTPUTF8. See test_email_valid_intl_local_part
# for addresses that are valid but require SMTPUTF8. Check that it passes with
# allow_smtput8 both on and off.
emailinfo = validate_email(email_input, check_deliverability=False, allow_smtputf8=False)
emailinfo = validate_email(email_input, check_deliverability=False, allow_smtputf8=False,
allow_quoted_local=True)
assert emailinfo == output
assert validate_email(email_input, check_deliverability=False, allow_smtputf8=True) == output
assert validate_email(email_input, check_deliverability=False, allow_smtputf8=True,
allow_quoted_local=True) == output

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

0 comments on commit 4161071

Please sign in to comment.