'Ensure that newlines in email reports\' subjects are escaped to avoid
AdminErrorHandler to fail.
Refs #17281.'

@override_settings(ADMINS=((u'admin', u'admin@example.com'),), EMAIL_SUBJECT_PREFIX=u'', DEBUG=False)
def test_subject_accepts_newlines(self):

    message = u'Message    \r\n    with    newlines'
    expected_subject = u'ERROR:    Message    \\r\\n    with    newlines'
    self.assertEqual(len(mail.outbox), 0)
    self.logger.error(message)
    self.assertEqual(len(mail.outbox), 1)
    self.assertFalse((u'\n' in mail.outbox[0].subject))
    self.assertFalse((u'\r' in mail.outbox[0].subject))
    self.assertEqual(mail.outbox[0].subject, expected_subject)
