Code

Opened 6 years ago

Closed 6 years ago

#6134 closed (fixed)

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

Reported by: jdetaeye Owned by: nobody
Component: Testing framework Version: master
Severity: Keywords: test sqlite
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 (2)

sqlitetest.patch (3.2 KB) - added by jdetaeye 6 years ago.
patch
testdocu.patch (3.7 KB) - added by jdetaeye 6 years ago.
Documentation patch

Download all attachments as: .zip

Change History (8)

Changed 6 years ago by jdetaeye

patch

comment:1 Changed 6 years ago by jdetaeye

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 6 years ago by jacob

  • Needs documentation set
  • Triage Stage changed from Design decision needed to Accepted

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

Changed 6 years ago by jdetaeye

Documentation patch

comment:3 Changed 6 years ago by jdetaeye

  • Needs documentation unset

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

comment:4 Changed 6 years ago by jdetaeye

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 6 years ago by mtredinnick

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

Refs #6134.

comment:6 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.