python3: update smtpd mock in tests (#40012)
This commit is contained in:
parent
926b32ed80
commit
7ca962ba6b
|
@ -11,6 +11,7 @@ import socket
|
|||
import threading
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from hobo.emails.validators import validate_email_address
|
||||
|
@ -46,8 +47,12 @@ def dns_resolver(monkeypatch):
|
|||
def smtp_server(monkeypatch):
|
||||
class RecipientValidatingSMTPChannel(smtpd.SMTPChannel):
|
||||
def smtp_RCPT(self, arg):
|
||||
address = self._SMTPChannel__getaddr('TO:', arg)
|
||||
domain = address.split('@')[-1]
|
||||
if six.PY2:
|
||||
address = self._SMTPChannel__getaddr('TO:', arg)
|
||||
domain = address.split('@')[-1]
|
||||
else:
|
||||
address = self._getaddr(arg)
|
||||
domain = address[1].split('@')[-1][:-1]
|
||||
if domain in ('example.com', 'example-spf.com', 'example-spf-allow-all.com', 'example-invalid-spf.com'):
|
||||
self._SMTPChannel__rcpttos.append(address)
|
||||
self.push('250 Ok')
|
||||
|
|
Loading…
Reference in New Issue