I've been handed a django-1.7 installation and asked to make testing work for an in-house django module. (specifically, we're running Django==1.7.9
and psycopg2==2.5.4
)
After two days of head scratching, I'm still finding that when I run manage.py test mymodule
, it's testing against the production postgres database rather than creating a test database into which to install my fixture data.
Weirdly, I don't get any error messages or any indicators that it's trying to create a test database at all. The testsuite simply tests against the production database.
I've verified that the user I'm running as has CREATE/DROP privileges in postgres for a test database.
I've also tried to get my testsuite to use an in-memory database by specifying a TEST
database engine as the built-in sqlite3, per the docs, like so:
DATABASES = {
'default': {
'NAME': DATABASE_NAME,
'PASSWORD': 'nottherealpassword',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'nottherealdbuser',
'PORT': '5432',
'HOST': '127.0.0.1',
'TEST': {
'ENGINE': 'django.db.backends.sqlite3'
}
},
}
No change in behavior with this configuration, either, and no indication that it's even trying to create one. Is there some scenario in which the test runner declines to even attempt to create a test database for a given module? I've tried both the default django runner as well as django_nose
with no change in behavior.
My preferred outcome will be to test against a tiny in-memory database that I'd populate with fixtures; my second preferred outcome would be to create a test database in postgres but without having to run every migration from the beginning of time.