Commit graph

8 commits

Author SHA1 Message Date
Claude
a2e6ea2eca
Raise ValueError instead of AssertionError for invalid arguments
User-facing argument validation in db.py previously used bare
assert statements, which vanish entirely under python -O and raise
AssertionError - an exception type callers should not have to
catch for input validation. Fifteen validation sites now raise
ValueError with the same messages. Internal invariants (an
unreachable branch and a post-update rowcount check) remain
asserts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UnLnhsH25Nnv7LHhekUfPd
2026-07-04 19:19:24 +00:00
Simon Willison
fd5b09f64b
Database as a context manager, fixed many pytest warnings
* Database can now work as a context manager
* Claude Code helped fix a ton of .close() warnings

https://gistpreview.github.io/?730f0c5dc38528a1dd0615f330bd5481

* New autouse fixture to help with test warnings

Refs https://github.com/simonw/sqlite-utils/issues/692#issuecomment-3644371889

* Fix all remaining resource warnings

https://gistpreview.github.io/?0bb8e869b82f6ff0db647de755182502

Closes #692
2025-12-11 16:56:12 -08:00
Simon Willison
c7e4308e6f Use new db.close() method, refs #504 2022-10-25 14:00:53 -07:00
Simon Willison
ba7242b1f2 Try closing the database before recreating it, refs #503 2022-10-25 13:36:17 -07:00
Simon Willison
f6b796277f Try a 0.1s sleep, refs #503 2022-10-25 13:27:18 -07:00
Simon Willison
079bf1f4dc Use tmp_path fixture in test_recreate, refs #503 2022-10-25 13:06:58 -07:00
Simon Willison
90e211e3e2 Now complies with flake8, refs #291 2021-06-22 18:22:08 -07:00
Simon Willison
729a3e7869 Tests for Database(..., recreate=True), refs #97 2020-04-12 20:47:36 -07:00