0001-emails-validators-ugettext_lazy-use-named-arguments-.patch
hobo/emails/validators.py | ||
---|---|---|
34 | 34 |
try: |
35 | 35 |
smtp.connect(mx_server) |
36 | 36 |
except socket.error as e: |
37 |
raise ValidationError(_('Error while connecting to %s: %s') % (mx_server, str(e)))
|
|
37 |
raise ValidationError(_('Error while connecting to %(server)s: %(msg)s') % {'server': mx_server, 'msg': str(e)})
|
|
38 | 38 |
status, msg = smtp.helo() |
39 | 39 |
if status != 250: |
40 | 40 |
smtp.quit() |
41 |
raise ValidationError(_('Error while connecting to %s: %s') % (mx_server, msg))
|
|
41 |
raise ValidationError(_('Error while connecting to %(server)s: %(msg)s') % {'server': mx_server, 'msg': msg})
|
|
42 | 42 |
smtp.mail('') |
43 | 43 |
status, msg = smtp.rcpt(value) |
44 | 44 |
if status == 250: |
tests/test_emails.py | ||
---|---|---|
83 | 83 |
monkeypatch.setattr('smtplib.SMTP.connect', socket_error) |
84 | 84 |
with pytest.raises(ValidationError) as e: |
85 | 85 |
validate_email_address('john.doe@example.com') |
86 |
assert 'Error' in str(e.value) |
|
86 |
assert 'Error while connecting' in str(e.value)
|
|
87 | 87 | |
88 | 88 | |
89 | 89 |
def test_invalid_address(client, admin_user): |
90 |
- |