Django Testing: no data in temporary database file Django Testing: no data in temporary database file sqlite sqlite

Django Testing: no data in temporary database file


Perhaps it has to do with how Django tests use transactions?

Check if the issue persists if you turn off all transactions in settings.py:

DISABLE_TRANSACTION_MANAGEMENT = True


Have you run the initial syncdb to create the database tables? (python yourproject/manage.py syncdb)

In your settings.py, what apps do you have installed under INSTALLED_APPS?

In your project, what models have you built?

Depending on what apps you have installed in INSTALLED_APPS and what custom models you have added to your project, will dictate what databases syncdb will create.


From the django documentation:

...When using the SQLite database engine the tests will by default use an in-memory database (i.e., the database will be created in memory, bypassing the filesystem entirely!). If you want to use a different database name, specify TEST_NAME in the dictionary for any given database in DATABASES.

Furthermore, if you read about fixture loading:

...At the start of each test case, before setUp() is run, Django will flush the database, returning the database to the state it was in directly after syncdb was called...

If you need a fresh database with some fixtures loaded you can of course do so by creating an empty database with running syncdb and load some fixtures with django-admin.py loaddata!