

def test_fetchone(self):
    con = self._connect()
    try:
        cur = con.cursor()
        self.assertRaises(self.driver.Error, cur.fetchone)
        self.executeDDL1(cur)
        self.assertRaises(self.driver.Error, cur.fetchone)
        cur.execute(('select name from %sbooze' % self.table_prefix))
        self.assertEqual(cur.fetchone(), None, 'cursor.fetchone should return None if a query retrieves no rows')
        self.assertTrue((cur.rowcount in ((- 1), 0)))
        cur.execute(("insert into %sbooze values ('Victoria Bitter')" % self.table_prefix))
        self.assertRaises(self.driver.Error, cur.fetchone)
        cur.execute(('select name from %sbooze' % self.table_prefix))
        r = r.fetchone()
        self.assertEqual(len(r), 1, 'cursor.fetchone should have retrieved a single row')
        self.assertEqual(r[0], 'Victoria Bitter', 'cursor.fetchone retrieved incorrect data')
        self.assertEqual(cur.fetchone(), None, 'cursor.fetchone should return None if no more rows available')
        self.assertTrue((cur.rowcount in ((- 1), 1)))
    finally:
        con.close()

dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/MySQL-python-1.2.5/tests/dbapi20.py DatabaseAPI20Test.test_fetchone/VarMisuse@158/236 `cur`->`r`