python-emails icon indicating copy to clipboard operation
python-emails copied to clipboard

Tests fail when running from home

Open vfaronov opened this issue 7 years ago • 2 comments

The following two tests:

  • emails/testsuite/message/test_send.py::test_send_letters
  • emails/testsuite/smtp/test_smtp_backend.py::test_smtp_send_with_reconnect

fail on my system, apparently because Microsoft rejects mail from home ISPs like mine (OnLime = Rostelecom):

smtp_servers = {'gmail.com-tls': <emails.testsuite.conftest.SMTPTestParams object at 0x7ff6a8dbccc0>, 'mx.yandex.ru': <emails.testsui...stParams object at 0x7ff6a8dbcc18>, 'outlook.com': <emails.testsuite.conftest.SMTPTestParams object at 0x7ff6a8dbcbe0>}

    def test_send_letters(smtp_servers):
    
        for m, render in get_letters():
            for tag, server in smtp_servers.items():
                server.patch_message(m)
                response = m.send(smtp=server.params, render=render)
                print(server.params)
>               assert response.success or response.status_code in (421, 451)  # gmail not always like test emails
E               assert (False or 550 in (421, 451))
E                +  where False = <emails.backend.SMTPResponse status_code=550 status_text=b"DY-001 (COL004-MC2F34) Unfortunately, messages from 188.32....ically-assigned IP ranges. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.">.success
E                +  and   550 = <emails.backend.SMTPResponse status_code=550 status_text=b"DY-001 (COL004-MC2F34) Unfortunately, messages from 188.32....ically-assigned IP ranges. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.">.status_code

emails/testsuite/message/test_send.py:35: AssertionError
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
{'timeout': 25, 'tls': True, 'fail_silently': True, 'port': 25, 'host': 'alt1.gmail-smtp-in.l.google.com', 'debug': 1}
{'fail_silently': True, 'timeout': 25, 'port': 25, 'host': 'mx.yandex.ru', 'debug': 1}
{'fail_silently': True, 'timeout': 25, 'host': 'mx1.hotmail.com', 'debug': 1}
-------------------------------------------------------- Captured stderr call ---------------------------------------------------------
[...skip...]
send: 'mail FROM:<[email protected]> size=4203\r\n'
reply: b"550 DY-001 (COL004-MC2F34) Unfortunately, messages from [MY.IP.ADDRESS.HERE] weren't sent. Please contact your Internet service provider. You can tell them that Hotmail does not relay dynamically-assigned IP ranges. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.\r\n"
reply: retcode (550); Msg: b"DY-001 (COL004-MC2F34) Unfortunately, messages from [MY.IP.ADDRESS.HERE] weren't sent. Please contact your Internet service provider. You can tell them that Hotmail does not relay dynamically-assigned IP ranges. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors."
send: 'rset\r\n'

The other two SMTP servers are OK.

vfaronov avatar Jul 07 '17 11:07 vfaronov

May be I should just skip this tests on local tests (actually - run them only in Travis)...

lavr avatar Jul 07 '17 22:07 lavr

I've added some environment variables for testing, now you can use local smtp:

$ TEST_SMTP_HOST=localhost TEST_SMTP_PORT=1025 tox

lavr avatar Jul 19 '17 11:07 lavr