FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-105539: Explict resource management for connection objects in sqlite3 tests by erlend-aasland · Pull Request #108017 · python/cpython · GitHub

Repository navigation

gh-105539: Explict resource management for connection objects in sqlite3 tests - #108017

Merged
erlend-aasland merged 4 commits into
python:mainfrom
erlend-aasland:sqlite/explicit-resource-handling-in-tests
Aug 17, 2023
Merged

erlend-aasland merged 4 commits into
python:mainfrom
erlend-aasland:sqlite/explicit-resource-handling-in-tests

Conversation

erlend-aasland commented Aug 16, 2023 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor Author

This PR either uses the memory_database() resource management helper from Lib/test/test_sqlite3/test_dbapi.py, or introduces explicit resource management via setUp()/tearDown() test case methods.

erlend-aasland added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Aug 16, 2023

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

I would suggest moving memory_database() to a new utils.py file. For me, it's surprising that tests import other tests. See for example Lib/test/test_asyncio/utils.py.

Comment thread Lib/test/test_sqlite3/test_dbapi.py Outdated

Copy link
Copy Markdown
Member

I don't know the DB API, but I'm surprised that with connect() as db: ... doesn't close the database :-(

Comment thread Lib/test/test_sqlite3/test_hooks.py Outdated
- Move test utility functions to util.py
- Use memory database mixin
- Add check() helper for closed connection tests
- Address other remarks by Nikita

Copy link
Copy Markdown
Contributor Author

I think all your remarks are addressed now; PTAL :)

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

If you want, you can replace from test.test_sqlite3.util import with from .util import.

Copy link
Copy Markdown
Contributor Author

Thanks for the review, Victor and Nikita!

sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

My first sqlite3 PR review ✅

erlend-aasland removed needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Aug 17, 2023
erlend-aasland merged commit 1344cfa into python:main Aug 17, 2023
erlend-aasland deleted the sqlite/explicit-resource-handling-in-tests branch August 17, 2023 06:46
erlend-aasland linked an issue Aug 23, 2023 that may be closed by this pull request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emit resource warning if sqlite3 fails to close the database

4 participants


Back | FazBrowse Home | New Git URL