I'm testing Django (v1.11.4) application in two setups of database: 1) postgres database running in docker container or 2) sqlite3 as (default database)
When running tests with --keepdb
option I observe different behavior for these two setups: for postgres --keepdb
works as expected (there is no database creation and running test is fast) but for sqlite3 database --keepdb
seems not working (for each run of the test there is creation of database).
Is it possible to have --keepdb
working with sqlite3? If so any idea what settings might affect behavior described as above?
By default, Django uses an in-memory database when testing sqlite. This means that the test database isn't persistent. You can override this behaviour in your DATABASES
setting by specifying a test name:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite',
'NAME': 'db.sqlite3',
'TEST': {
'NAME': 'testdb.sqlite3',
},
},
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With