#33184 closed New feature (wontfix)
Allow a way to create a new test database AND keep it for the next test run
Reported by: | Valentijn Scholten | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 3.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I am running multiple test suites serially. I'd like to ensure the first starts with a fresh test database, but reuse that database in the following test runs.
Currently (to my undestanding) this is not possible with --keepdb
or any of the other parameters.
The --keepdb
flag when running tests does two things:
1) Reuse existing test database if found
2) Leave test database intact after completing the tests
So step 1 prevents me from obtaining my desired scenario.
I could run the tests without --keepdb
and use --no-input
to force the creation of a new test database. But in that case the database will be destroyed after running the tests.
Suggestion:
- Add a '--createdb
parameter to "force" the creation of a new test database, while allowing
--keepdb` to be used in the same run.
Change History (2)
comment:2 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I am running multiple test suites serially. ...
Assuming I've understood correctly, I think Mateusz's is right.
- Use
--keepdb
for all runs, which should create the DB on the first pass. - Run
dropdb
(Postgres) orrm
(Sqlite) or equivalent, after the last run.
For the dropdb
step, I don't think that replicating existing tools inside django-admin
is going to be worth it.
As I understand doc, it should work without no input, but you have to destroy database after last test.
"You can prevent the test databases from being destroyed by using the test --keepdb option. This will preserve the test database between runs. If the database does not exist, it will first be created. Any migrations will also be applied in order to keep it up to date."