-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
35 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
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 |
---|---|---|
@@ -1,16 +1,25 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from email_validator import EmailSyntaxError, \ | ||
validate_email, \ | ||
ValidatedEmail | ||
|
||
|
||
def MakeValidatedEmail(**kwargs: Any) -> ValidatedEmail: | ||
ret = ValidatedEmail() | ||
for k, v in kwargs.items(): | ||
setattr(ret, k, v) | ||
return ret | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'email_input,output', | ||
[ | ||
( | ||
'[email protected]', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='Abc', | ||
ascii_local_part='Abc', | ||
smtputf8=False, | ||
|
@@ -22,7 +31,7 @@ | |
), | ||
( | ||
'[email protected]', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='Abc.123', | ||
ascii_local_part='Abc.123', | ||
smtputf8=False, | ||
|
@@ -34,7 +43,7 @@ | |
), | ||
( | ||
'user+mailbox/[email protected]', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='user+mailbox/department=shipping', | ||
ascii_local_part='user+mailbox/department=shipping', | ||
smtputf8=False, | ||
|
@@ -46,7 +55,7 @@ | |
), | ||
( | ||
"!#$%&'*+-/=?^_`.{|}[email protected]", | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part="!#$%&'*+-/=?^_`.{|}~", | ||
ascii_local_part="!#$%&'*+-/=?^_`.{|}~", | ||
smtputf8=False, | ||
|
@@ -58,7 +67,7 @@ | |
), | ||
( | ||
'jeff@臺網中心.tw', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='jeff', | ||
ascii_local_part='jeff', | ||
smtputf8=False, | ||
|
@@ -70,7 +79,7 @@ | |
), | ||
( | ||
'"quoted local part"@example.org', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='"quoted local part"', | ||
ascii_local_part='"quoted local part"', | ||
smtputf8=False, | ||
|
@@ -82,7 +91,7 @@ | |
), | ||
( | ||
'"de-quoted.local.part"@example.org', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='de-quoted.local.part', | ||
ascii_local_part='de-quoted.local.part', | ||
smtputf8=False, | ||
|
@@ -94,7 +103,7 @@ | |
), | ||
( | ||
'MyName <[email protected]>', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='me', | ||
ascii_local_part='me', | ||
smtputf8=False, | ||
|
@@ -107,7 +116,7 @@ | |
), | ||
( | ||
'My Name <[email protected]>', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='me', | ||
ascii_local_part='me', | ||
smtputf8=False, | ||
|
@@ -120,7 +129,7 @@ | |
), | ||
( | ||
r'"My.\"Na\\me\".Is" <"me \" \\ me"@example.org>', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part=r'"me \" \\ me"', | ||
ascii_local_part=r'"me \" \\ me"', | ||
smtputf8=False, | ||
|
@@ -157,7 +166,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
[ | ||
( | ||
'伊昭傑@郵件.商務', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='伊昭傑', | ||
smtputf8=True, | ||
ascii_domain='xn--5nqv22n.xn--lhr59c', | ||
|
@@ -167,7 +176,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'राम@मोहन.ईन्फो', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='राम', | ||
smtputf8=True, | ||
ascii_domain='xn--l2bl7a9d.xn--o1b8dj2ki', | ||
|
@@ -177,7 +186,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'юзер@екзампл.ком', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='юзер', | ||
smtputf8=True, | ||
ascii_domain='xn--80ajglhfv.xn--j1aef', | ||
|
@@ -187,7 +196,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'θσερ@εχαμπλε.ψομ', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='θσερ', | ||
smtputf8=True, | ||
ascii_domain='xn--mxahbxey0c.xn--xxaf0a', | ||
|
@@ -197,7 +206,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'葉士豪@臺網中心.tw', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='葉士豪', | ||
smtputf8=True, | ||
ascii_domain='xn--fiqq24b10vi0d.tw', | ||
|
@@ -207,7 +216,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'葉士豪@臺網中心.台灣', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='葉士豪', | ||
smtputf8=True, | ||
ascii_domain='xn--fiqq24b10vi0d.xn--kpry57d', | ||
|
@@ -217,7 +226,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'jeff葉@臺網中心.tw', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='jeff葉', | ||
smtputf8=True, | ||
ascii_domain='xn--fiqq24b10vi0d.tw', | ||
|
@@ -227,7 +236,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'ñoñó@example.tld', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='ñoñó', | ||
smtputf8=True, | ||
ascii_domain='example.tld', | ||
|
@@ -237,7 +246,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'我買@example.tld', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='我買', | ||
smtputf8=True, | ||
ascii_domain='example.tld', | ||
|
@@ -247,7 +256,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'甲斐黒川日本@example.tld', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='甲斐黒川日本', | ||
smtputf8=True, | ||
ascii_domain='example.tld', | ||
|
@@ -257,7 +266,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'чебурашкаящик-с-апельсинами.рф@example.tld', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='чебурашкаящик-с-апельсинами.рф', | ||
smtputf8=True, | ||
ascii_domain='example.tld', | ||
|
@@ -267,7 +276,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'उदाहरण.परीक्ष@domain.with.idn.tld', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='उदाहरण.परीक्ष', | ||
smtputf8=True, | ||
ascii_domain='domain.with.idn.tld', | ||
|
@@ -277,7 +286,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None: | |
), | ||
( | ||
'ιωάννης@εεττ.gr', | ||
ValidatedEmail( | ||
MakeValidatedEmail( | ||
local_part='ιωάννης', | ||
smtputf8=True, | ||
ascii_domain='xn--qxaa9ba.gr', | ||
|