Improve test_sqlite3.test_sqlite_row_iter · Issue #100553 · python/cpython (original) (raw)

While working on #100457 I've noticed that test_sqlite_row_iter can be improved. Right now it is defined as:

def test_sqlite_row_iter(self):
    """Checks if the row object is iterable"""
    self.con.row_factory = sqlite.Row
    row = self.con.execute("select 1 as a, 2 as b").fetchone()
    for col in row:
       pass

Well, there are several issues:

  1. We do not check what values it actually returns
  2. We do not check whether or not it is iterable the second time, because some types are implemented as generators and cannot be iterated over the second time

I will send a PR with the improved test.

Linked PRs