1.7.9 deployment stubbornly won't create a test database

19 views
Skip to first unread message

Adam Hirsch

unread,
Aug 29, 2016, 8:07:38 PM8/29/16
to Django users
I've been handed a fairly large and built-up django 1.7.9 installation with several dozen pre-existing in-house modules and a lot of history. 

For some reason, any attempt to  manage.py test  any of the existing modules runs tests against the live database specified in DATABASES['default'] rather than attempting to create a new test database.  I've written a couple of simple unit tests for a given module, generated a small fixture of data to apply to a blank schema for testing ... but I can't for the life of me find why this installation isn't creating a test_db. No errors, no failures ... just tests run against the production db.

Anyone have a pointer to what might be going on, or concepts to look up? A simple Hello World install using the same django version on the same machine works exactly as the docs suggest it should: I see 

Creating test database for alias 'default' (':memory:')...
[...]
Destroying test database for alias 'default' (':memory:')...

... but there are no such lines in my real installation.  I'm baffled.

Adam

 

M Hashmi

unread,
Aug 30, 2016, 7:52:33 PM8/30/16
to django...@googlegroups.com
Try this:

python manage.py test --keepdb

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ea373ba9-9c9e-4358-9c71-b3c0d1c4b3d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andromeda Yelton

unread,
Aug 30, 2016, 7:59:30 PM8/30/16
to django...@googlegroups.com
What are do the relevant parts of your settings file say? In particular, https://docs.djangoproject.com/en/1.7/topics/testing/overview/#the-test-database says "If you want to use a different database name, specify NAME in the TEST dictionary for any given database in DATABASES." - I would check there to see if someone has overridden the default. There's also a little section in the docs labeled "Finding data from your production database when running tests?" that might be relevant to you.

(--keepdb is a great flag but sadly irrelevant as it was not introduced until 1.8.)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ea373ba9-9c9e-4358-9c71-b3c0d1c4b3d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology Association: http://www.lita.org

M Hashmi

unread,
Aug 30, 2016, 8:04:01 PM8/30/16
to django...@googlegroups.com
My bad...missed the version in original question. 

You are right.

Adam Hirsch

unread,
Aug 30, 2016, 11:15:25 PM8/30/16
to Django users
And the answer turned out to be... we were/are using a multidb setup, which silently prevents the test suite from creating a test db. Setting DATABASE_ROUTERS = [] re-enabled the test db creation. Sigh. It's always the little things.
Reply all
Reply to author
Forward
0 new messages