Sitelet https://github.com/python/cpython/issues/100553
Skip to content

Improve test_sqlite3.test_sqlite_row_iter #100553

Description

@sobolevn

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

Activity

  1. self-assigned this
    on Dec 27, 2022
  2. changed the title [-]Improve `test_[/-] [+]Improve `test_sqlite3.test_sqlite_row_iter`[/+] on Dec 27, 2022
  3. added 2 commits that reference this issue on Dec 27, 2022
  4. pochmann commented on Dec 27, 2022

    @pochmann
    Contributor

    Also, col and items are misleading names, better use value and values (that's what the Row documentation calls them).

  5. added a commit that references this issue on Dec 28, 2022
  6. added 2 commits that reference this issue on Dec 28, 2022
  7. erlend-aasland commented on Dec 28, 2022

    @erlend-aasland
    Contributor

    Thanks, Nikita, good catch!

  8. added 2 commits that reference this issue on Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtopic-sqlite3type-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions