-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests that quoted local parts are unquoted in the returned normal…
…ized address where possible
- Loading branch information
Showing
2 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|