@@ -22,26 +22,20 @@ def test_deliverability_found(domain, expected_response):
22
22
assert response == expected_response
23
23
24
24
25
- def test_deliverability_fails ():
26
- # Domain does not exist.
27
- domain = 'xkxufoekjvjfjeodlfmdfjcu.com'
28
- with pytest .raises (EmailUndeliverableError , match = f'The domain name { domain } does not exist' ):
29
- validate_email_deliverability (domain , domain , dns_resolver = RESOLVER )
30
-
31
- # Null MX record.
32
- domain = 'example.com'
33
- with pytest .raises (EmailUndeliverableError , match = f'The domain name { domain } does not accept email' ):
34
- validate_email_deliverability (domain , domain , dns_resolver = RESOLVER )
35
-
36
- # No MX record, A record fallback, reject-all SPF record.
37
- domain = 'nellis.af.mil'
38
- with pytest .raises (EmailUndeliverableError , match = f'The domain name { domain } does not send email' ):
39
- validate_email_deliverability (domain , domain , dns_resolver = RESOLVER )
25
+ @pytest .mark .parametrize (
26
+ 'domain,error' ,
27
+ [
28
+ ('xkxufoekjvjfjeodlfmdfjcu.com' , 'The domain name {domain} does not exist' ),
29
+ ('example.com' , 'The domain name {domain} does not accept email' ), # Null MX record
30
+ ('nellis.af.mil' , 'The domain name {domain} does not send email' ), # No MX record, A record fallback, reject-all SPF record.
40
31
41
- # No MX or A/AAAA records, but some other DNS records must
42
- # exist such that the response is NOANSWER instead of NXDOMAIN.
43
- domain = 'justtxt.joshdata.me'
44
- with pytest .raises (EmailUndeliverableError , match = f'The domain name { domain } does not accept email' ):
32
+ # No MX or A/AAAA records, but some other DNS records must
33
+ # exist such that the response is NOANSWER instead of NXDOMAIN.
34
+ ('justtxt.joshdata.me' , 'The domain name {domain} does not accept email' ),
35
+ ],
36
+ )
37
+ def test_deliverability_fails (domain , error ):
38
+ with pytest .raises (EmailUndeliverableError , match = error .format (domain = domain )):
45
39
validate_email_deliverability (domain , domain , dns_resolver = RESOLVER )
46
40
47
41
0 commit comments