'The connection can be used as a contextmanager.'

def test_use_as_contextmanager(self):

    opened = [False]
    closed = [False]
    conn = mail.get_connection(username='', password='')
    def open():
        opened[0] = True
    conn.open = open
    def close():
        closed[0] = True
    conn.close = close
    with conn as same_conn:
        self.assertTrue(opened[0])
        self.assertIs(same_conn, conn)
        self.assertFalse(closed[0])
    self.assertTrue(closed[0])
