Skip to content

Commit 8ec4239

Browse files
committed
Parameterize test_deliverability_fails
1 parent da48fd1 commit 8ec4239

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

tests/test_deliverability.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,20 @@ def test_deliverability_found(domain, expected_response):
2222
assert response == expected_response
2323

2424

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.
4031
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)):
4539
validate_email_deliverability(domain, domain, dns_resolver=RESOLVER)
4640

4741

0 commit comments

Comments
 (0)