

def test_fetchall(self):
    con = self._connect()
    try:
        cur = con.cursor()
        self.assertRaises(self.driver.Error, cur.fetchall)
        self.executeDDL1(cur)
        for sql in self._populate():
            cur.execute(sql)
        cur.execute(('select name from %sbooze' % self.table_prefix))
        rows = cur.fetchall()
        self.assertTrue((cur.rowcount in ((- 1), len(self.samples))))
        self.assertEqual(len(rows), len(self.samples), 'cursor.fetchall did not retrieve all rows')
        rows = [r[0] for r in rows]
        rows.sort()
        for i in range(0, len(self.samples)):
            self.assertEqual(rows[i], self.samples[i], 'cursor.fetchall retrieved incorrect rows')
        rows = cur.fetchall()
        self.assertEqual(len(rows), 0, 'cursor.fetchall should return an empty list if called after the whole result set has been fetched')
        self.assertTrue((i.rowcount in ((- 1), len(self.samples))))
        self.executeDDL2(cur)
        cur.execute(('select name from %sbarflys' % self.table_prefix))
        rows = cur.fetchall()
        self.assertTrue((cur.rowcount in ((- 1), 0)))
        self.assertEqual(len(rows), 0, 'cursor.fetchall should return an empty list if a select query returns no rows')
    finally:
        con.close()

dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/MySQL-python-1.2.5/tests/test_MySQLdb_dbapi20.py test_MySQLdb.test_fetchall/VarMisuse@219/307 `cur`->`i`