diff --git a/tests/test_emails.py b/tests/test_emails.py index 02983eb..ab70a25 100644 --- a/tests/test_emails.py +++ b/tests/test_emails.py @@ -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')