[Django] #33184: Allow a way to create a new test database AND keep it for the next test run

6 views
Skip to first unread message

Django

unread,
Oct 9, 2021, 1:12:28 PM10/9/21
to django-...@googlegroups.com
#33184: Allow a way to create a new test database AND keep it for the next test run
---------------------------------------------+------------------------
Reporter: valentijnscholten | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/33184>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 11, 2021, 4:40:20 AM10/11/21
to django-...@googlegroups.com
#33184: Allow a way to create a new test database AND keep it for the next test run
------------------------------------+--------------------------------------
Reporter: Valentijn Scholten | Owner: nobody

Type: New feature | Status: new
Component: Testing framework | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------

Comment (by mleszko):

Why add parameter when you can just create db in separate command?

--
Ticket URL: <https://code.djangoproject.com/ticket/33184#comment:1>

Django

unread,
Oct 12, 2021, 4:22:58 AM10/12/21
to django-...@googlegroups.com
#33184: Allow a way to create a new test database AND keep it for the next test run
------------------------------------+--------------------------------------
Reporter: Valentijn Scholten | Owner: nobody
Type: New feature | Status: closed

Component: Testing framework | Version: 3.2
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => wontfix


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/33184#comment:2>

Reply all
Reply to author
Forward
0 new messages