Example #1
0
def test_to_console_stream_kwarg():
    """Test that the console backend can be pointed at an arbitrary stream.
    """
    s = StringIO()
    mailer = ToConsoleMailer(stream=s)
    email1 = EmailMessage("Subject", "Content", "*****@*****.**", "*****@*****.**")
    mailer.send(email1)

    value = s.getvalue()
    assert value.startswith(
        'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nSubject: Subject\nFrom: [email protected]\nTo: [email protected]\nDate: '
    )
Example #2
0
def test_to_console_mailer():
    __stdout = sys.stdout
    s = sys.stdout = StringIO()

    mailer = ToConsoleMailer()
    email1 = EmailMessage("Subject", "Content", "*****@*****.**", "*****@*****.**")
    mailer.send(email1)

    value = s.getvalue()
    assert value.startswith(
        'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nSubject: Subject\nFrom: [email protected]\nTo: [email protected]\nDate: '
    )

    sys.stdout = __stdout