(self)
| 530 | return populate |
| 531 | |
| 532 | def test_fetchmany(self): |
| 533 | con = self._connect() |
| 534 | try: |
| 535 | cur = con.cursor() |
| 536 | |
| 537 | # cursor.fetchmany should raise an Error if called without |
| 538 | # issuing a query |
| 539 | self.assertRaises(self.driver.Error, cur.fetchmany, 4) |
| 540 | |
| 541 | self.executeDDL1(cur) |
| 542 | for sql in self._populate(): |
| 543 | cur.execute(sql) |
| 544 | |
| 545 | cur.execute("select name from %sbooze" % self.table_prefix) |
| 546 | r = cur.fetchmany() |
| 547 | self.assertEqual( |
| 548 | len(r), |
| 549 | 1, |
| 550 | "cursor.fetchmany retrieved incorrect number of rows, " |
| 551 | "default of arraysize is one.", |
| 552 | ) |
| 553 | cur.arraysize = 10 |
| 554 | r = cur.fetchmany(3) # Should get 3 rows |
| 555 | self.assertEqual( |
| 556 | len(r), 3, "cursor.fetchmany retrieved incorrect number of rows" |
| 557 | ) |
| 558 | r = cur.fetchmany(4) # Should get 2 more |
| 559 | self.assertEqual( |
| 560 | len(r), 2, "cursor.fetchmany retrieved incorrect number of rows" |
| 561 | ) |
| 562 | r = cur.fetchmany(4) # Should be an empty sequence |
| 563 | self.assertEqual( |
| 564 | len(r), |
| 565 | 0, |
| 566 | "cursor.fetchmany should return an empty sequence after " |
| 567 | "results are exhausted", |
| 568 | ) |
| 569 | self.assertTrue(cur.rowcount in (-1, 6)) |
| 570 | |
| 571 | # Same as above, using cursor.arraysize |
| 572 | cur.arraysize = 4 |
| 573 | cur.execute("select name from %sbooze" % self.table_prefix) |
| 574 | r = cur.fetchmany() # Should get 4 rows |
| 575 | self.assertEqual( |
| 576 | len(r), 4, "cursor.arraysize not being honoured by fetchmany" |
| 577 | ) |
| 578 | r = cur.fetchmany() # Should get 2 more |
| 579 | self.assertEqual(len(r), 2) |
| 580 | r = cur.fetchmany() # Should be an empty sequence |
| 581 | self.assertEqual(len(r), 0) |
| 582 | self.assertTrue(cur.rowcount in (-1, 6)) |
| 583 | |
| 584 | cur.arraysize = 6 |
| 585 | cur.execute("select name from %sbooze" % self.table_prefix) |
| 586 | rows = cur.fetchmany() # Should get all rows |
| 587 | self.assertTrue(cur.rowcount in (-1, 6)) |
| 588 | self.assertEqual(len(rows), 6) |
| 589 | self.assertEqual(len(rows), 6) |
nothing calls this directly
no test coverage detected