'Test connection argument to send_mail(), et. al.'

@override_settings(EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend', ADMINS=[('nobody', 'nobody@example.com')], MANAGERS=[('nobody', 'nobody@example.com')])
def test_connection_arg(self):

    mail.outbox = []
    connection = mail.get_connection('mail.custombackend.EmailBackend')
    send_mail('Subject', 'Content', 'from@example.com', ['to@example.com'], connection=connection)
    self.assertEqual(mail.outbox, [])
    self.assertEqual(len(connection.test_outbox), 1)
    self.assertEqual(connection.test_outbox[0].subject, 'Subject')
    connection = mail.get_connection('mail.custombackend.EmailBackend')
    send_mass_mail([('Subject1', 'Content1', 'from1@example.com', ['to1@example.com']), ('Subject2', 'Content2', 'from2@example.com', ['to2@example.com'])], connection=connection)
    self.assertEqual(mail.outbox, [])
    self.assertEqual(len(connection.test_outbox), 2)
    self.assertEqual(connection.test_outbox[0].subject, 'Subject1')
    self.assertEqual(connection.test_outbox[1].subject, 'Subject2')
    connection = mail.get_connection('mail.custombackend.EmailBackend')
    mail_admins('Admin    message', 'Content', connection=connection)
    self.assertEqual(mail.outbox, [])
    self.assertEqual(len(connection.test_outbox), 1)
    self.assertEqual(connection.test_outbox[0].subject, '[Django]    Admin    message')
    connection = mail.get_connection('mail.custombackend.EmailBackend')
    mail_managers('Manager    message', 'Content', connection=connection)
    self.assertEqual(mail.outbox, [])
    self.assertEqual(len(connection.test_outbox), 1)
    self.assertEqual(connection.test_outbox[0].subject, '[Django]    Manager    message')
