Warn when --reuse-db is used with an in-memory sqlite database - #1310
Open
ChrisJr404 wants to merge 2 commits into
Open
Warn when --reuse-db is used with an in-memory sqlite database#1310ChrisJr404 wants to merge 2 commits into
ChrisJr404 wants to merge 2 commits into
Conversation
An in-memory sqlite database only exists for the lifetime of the process, so --reuse-db has nothing to reuse or keep. Emit a warning in that case to avoid the confusion reported in pytest-dev#160.
kingbuzzman
reviewed
Aug 27, 2026
Author
|
Renamed the variable to On the |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #160.
Using
--reuse-dbwith an in-memory sqlite database is a no-op: the database only lives for the duration of the process, so there's nothing to reuse or keep between runs. This trips people up (the default sqlite test database is in-memory), which is what the issue describes, and both Andreas and Daniel agreed a warning would be the right nudge.So this emits a
PytestWarningfromdjango_db_setupwhen--reuse-dbis requested (and--create-dbisn't) and any of the databases being set up is an in-memory sqlite one. It only fires when you actually pass--reuse-db, so default runs are unaffected. Uses the samevendor == "sqlite" and is_in_memory_db()check already used for the live server.Added tests for both the warning firing and staying quiet without the flag, plus a changelog line and a short note in the database docs.