1
+ from typing import Any
2
+
1
3
import pytest
2
4
3
5
from email_validator import EmailSyntaxError , \
4
6
validate_email , \
5
7
ValidatedEmail
6
8
7
9
10
+ def MakeValidatedEmail (** kwargs : Any ) -> ValidatedEmail :
11
+ ret = ValidatedEmail ()
12
+ for k , v in kwargs .items ():
13
+ setattr (ret , k , v )
14
+ return ret
15
+
16
+
8
17
@pytest .mark .parametrize (
9
18
'email_input,output' ,
10
19
[
11
20
(
12
21
'Abc@example.tld' ,
13
- ValidatedEmail (
22
+ MakeValidatedEmail (
14
23
local_part = 'Abc' ,
15
24
ascii_local_part = 'Abc' ,
16
25
smtputf8 = False ,
22
31
),
23
32
(
24
33
'Abc.123@test-example.com' ,
25
- ValidatedEmail (
34
+ MakeValidatedEmail (
26
35
local_part = 'Abc.123' ,
27
36
ascii_local_part = 'Abc.123' ,
28
37
smtputf8 = False ,
34
43
),
35
44
(
36
45
'user+mailbox/department=shipping@example.tld' ,
37
- ValidatedEmail (
46
+ MakeValidatedEmail (
38
47
local_part = 'user+mailbox/department=shipping' ,
39
48
ascii_local_part = 'user+mailbox/department=shipping' ,
40
49
smtputf8 = False ,
46
55
),
47
56
(
48
57
"!#$%&'*+-/=?^_`.{|}~@example.tld" ,
49
- ValidatedEmail (
58
+ MakeValidatedEmail (
50
59
local_part = "!#$%&'*+-/=?^_`.{|}~" ,
51
60
ascii_local_part = "!#$%&'*+-/=?^_`.{|}~" ,
52
61
smtputf8 = False ,
58
67
),
59
68
(
60
69
'jeff@臺網中心.tw' ,
61
- ValidatedEmail (
70
+ MakeValidatedEmail (
62
71
local_part = 'jeff' ,
63
72
ascii_local_part = 'jeff' ,
64
73
smtputf8 = False ,
70
79
),
71
80
(
72
81
'"quoted local part"@example.org' ,
73
- ValidatedEmail (
82
+ MakeValidatedEmail (
74
83
local_part = '"quoted local part"' ,
75
84
ascii_local_part = '"quoted local part"' ,
76
85
smtputf8 = False ,
82
91
),
83
92
(
84
93
'"de-quoted.local.part"@example.org' ,
85
- ValidatedEmail (
94
+ MakeValidatedEmail (
86
95
local_part = 'de-quoted.local.part' ,
87
96
ascii_local_part = 'de-quoted.local.part' ,
88
97
smtputf8 = False ,
94
103
),
95
104
(
96
105
'MyName <me@example.org>' ,
97
- ValidatedEmail (
106
+ MakeValidatedEmail (
98
107
local_part = 'me' ,
99
108
ascii_local_part = 'me' ,
100
109
smtputf8 = False ,
107
116
),
108
117
(
109
118
'My Name <me@example.org>' ,
110
- ValidatedEmail (
119
+ MakeValidatedEmail (
111
120
local_part = 'me' ,
112
121
ascii_local_part = 'me' ,
113
122
smtputf8 = False ,
120
129
),
121
130
(
122
131
r'"My.\"Na\\me\".Is" <"me \" \\ me"@example.org>' ,
123
- ValidatedEmail (
132
+ MakeValidatedEmail (
124
133
local_part = r'"me \" \\ me"' ,
125
134
ascii_local_part = r'"me \" \\ me"' ,
126
135
smtputf8 = False ,
@@ -157,7 +166,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
157
166
[
158
167
(
159
168
'伊昭傑@郵件.商務' ,
160
- ValidatedEmail (
169
+ MakeValidatedEmail (
161
170
local_part = '伊昭傑' ,
162
171
smtputf8 = True ,
163
172
ascii_domain = 'xn--5nqv22n.xn--lhr59c' ,
@@ -167,7 +176,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
167
176
),
168
177
(
169
178
'राम@मोहन.ईन्फो' ,
170
- ValidatedEmail (
179
+ MakeValidatedEmail (
171
180
local_part = 'राम' ,
172
181
smtputf8 = True ,
173
182
ascii_domain = 'xn--l2bl7a9d.xn--o1b8dj2ki' ,
@@ -177,7 +186,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
177
186
),
178
187
(
179
188
'юзер@екзампл.ком' ,
180
- ValidatedEmail (
189
+ MakeValidatedEmail (
181
190
local_part = 'юзер' ,
182
191
smtputf8 = True ,
183
192
ascii_domain = 'xn--80ajglhfv.xn--j1aef' ,
@@ -187,7 +196,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
187
196
),
188
197
(
189
198
'θσερ@εχαμπλε.ψομ' ,
190
- ValidatedEmail (
199
+ MakeValidatedEmail (
191
200
local_part = 'θσερ' ,
192
201
smtputf8 = True ,
193
202
ascii_domain = 'xn--mxahbxey0c.xn--xxaf0a' ,
@@ -197,7 +206,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
197
206
),
198
207
(
199
208
'葉士豪@臺網中心.tw' ,
200
- ValidatedEmail (
209
+ MakeValidatedEmail (
201
210
local_part = '葉士豪' ,
202
211
smtputf8 = True ,
203
212
ascii_domain = 'xn--fiqq24b10vi0d.tw' ,
@@ -207,7 +216,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
207
216
),
208
217
(
209
218
'葉士豪@臺網中心.台灣' ,
210
- ValidatedEmail (
219
+ MakeValidatedEmail (
211
220
local_part = '葉士豪' ,
212
221
smtputf8 = True ,
213
222
ascii_domain = 'xn--fiqq24b10vi0d.xn--kpry57d' ,
@@ -217,7 +226,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
217
226
),
218
227
(
219
228
'jeff葉@臺網中心.tw' ,
220
- ValidatedEmail (
229
+ MakeValidatedEmail (
221
230
local_part = 'jeff葉' ,
222
231
smtputf8 = True ,
223
232
ascii_domain = 'xn--fiqq24b10vi0d.tw' ,
@@ -227,7 +236,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
227
236
),
228
237
(
229
238
'ñoñó@example.tld' ,
230
- ValidatedEmail (
239
+ MakeValidatedEmail (
231
240
local_part = 'ñoñó' ,
232
241
smtputf8 = True ,
233
242
ascii_domain = 'example.tld' ,
@@ -237,7 +246,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
237
246
),
238
247
(
239
248
'我買@example.tld' ,
240
- ValidatedEmail (
249
+ MakeValidatedEmail (
241
250
local_part = '我買' ,
242
251
smtputf8 = True ,
243
252
ascii_domain = 'example.tld' ,
@@ -247,7 +256,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
247
256
),
248
257
(
249
258
'甲斐黒川日本@example.tld' ,
250
- ValidatedEmail (
259
+ MakeValidatedEmail (
251
260
local_part = '甲斐黒川日本' ,
252
261
smtputf8 = True ,
253
262
ascii_domain = 'example.tld' ,
@@ -257,7 +266,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
257
266
),
258
267
(
259
268
'чебурашкаящик-с-апельсинами.рф@example.tld' ,
260
- ValidatedEmail (
269
+ MakeValidatedEmail (
261
270
local_part = 'чебурашкаящик-с-апельсинами.рф' ,
262
271
smtputf8 = True ,
263
272
ascii_domain = 'example.tld' ,
@@ -267,7 +276,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
267
276
),
268
277
(
269
278
'उदाहरण.परीक्ष@domain.with.idn.tld' ,
270
- ValidatedEmail (
279
+ MakeValidatedEmail (
271
280
local_part = 'उदाहरण.परीक्ष' ,
272
281
smtputf8 = True ,
273
282
ascii_domain = 'domain.with.idn.tld' ,
@@ -277,7 +286,7 @@ def test_email_valid(email_input: str, output: ValidatedEmail) -> None:
277
286
),
278
287
(
279
288
'ιωάννης@εεττ.gr' ,
280
- ValidatedEmail (
289
+ MakeValidatedEmail (
281
290
local_part = 'ιωάννης' ,
282
291
smtputf8 = True ,
283
292
ascii_domain = 'xn--qxaa9ba.gr' ,
0 commit comments