Django

Code

Ticket #6134 (closed: fixed)

Opened 9 months ago

Last modified 9 months ago

Enhancement to run SQLite unit tests with a database file, rather than in-memory db

Reported by: jdetaeye Assigned to: nobody
Milestone: Component: Unit test system
Version: SVN Keywords: test sqlite
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

In my application and its test suite I also run an external process to process some data in the database. When using the SQLite database engine I can't use the in-memory database that is: it's only visible inside the python process running the test...

For other database engines, one can use the TEST_DATABASE_NAME to choose the database to use for the tests, but no such override capability is possible with SQLite.

This patch corrects this "unfair" inbalance:
1. When no TEST_DATABASE_NAME is specified in the settings file, it defaults to ":memory:", ie current behavior
2. If a TEST_DATABASE_NAME setting is present and it's different from ":memory:" we try to delete the database file before running the tests. Similar as the other database engines, the user is prompted for confirmation.
3. When the tests have finished, the test database file is deleted.

Since this change is backwards-incompatible, a design decision is required on this ticket.

Attachments

sqlitetest.patch (3.2 kB) - added by jdetaeye on 12/05/07 09:22:44.
patch
testdocu.patch (3.7 kB) - added by jdetaeye on 12/06/07 02:18:10.
Documentation patch

Change History

12/05/07 09:22:44 changed by jdetaeye

  • attachment sqlitetest.patch added.

patch

12/05/07 09:27:34 changed by jdetaeye

  • needs_better_patch changed.
  • stage changed from Unreviewed to Design decision needed.
  • needs_tests changed.
  • needs_docs changed.

12/05/07 10:27:53 changed by jacob

  • needs_docs set to 1.
  • stage changed from Design decision needed to Accepted.

Seems reasonable. Needs a patch to the docs of TEST_DATABASE_NAME, but otherwise looks OK.

12/06/07 02:18:10 changed by jdetaeye

  • attachment testdocu.patch added.

Documentation patch

12/06/07 02:23:10 changed by jdetaeye

  • needs_docs deleted.

The documentation patch goes a little further than only documenting this settings change.

The documentation on the unit tests described the test database and its settings under the section Understanding the test output. I believe the text is cleared and easier to read when the test database is covered in a seperate section The test database.

Feel free to revise and update further...

12/07/07 07:52:14 changed by jdetaeye

  • stage changed from Accepted to Ready for checkin.

12/17/07 02:50:32 changed by mtredinnick

(In [6929]) Split up the documentation of the test database and the test output.

Refs #6134.

12/17/07 02:50:51 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [6930]) Fixed #6134 -- Allow an on-disk SQLite database to be used for tests, if required. Patch from jdetaeye.


Add/Change #6134 (Enhancement to run SQLite unit tests with a database file, rather than in-memory db)




Change Properties
Action