Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#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:1 by Mateusz Leszko, 3 years ago

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."

Last edited 3 years ago by Mateusz Leszko (previous) (diff)

comment:2 by Carlton Gibson, 3 years ago

Resolution: wontfix
Status: newclosed

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) or rm (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.

Version 0, edited 3 years ago by Carlton Gibson (next)
Note: See TracTickets for help on using tickets.
Back to Top