Search code examples
djangodjango-testingdjango-manage.py

Why doesn't Django's test command recognize some options?


I'm running a project on Django 1.8.12 and I'd like to preserve test database between runs as described in the documentation. Even though the test command itself lists the -k/--keepdb option in help text, using it fails:

vagrant@vagrant /vagrant/project (master) $ python manage.py test -k myapp.tests.testcase
nosetests myapp.tests.testcase -k --verbosity=1
Usage: manage.py [options]

manage.py: error: no such option: -k

vagrant@vagrant /vagrant/project (master) $ python manage.py test --keepdb myapp.tests.testcase
nosetests myapp.tests.testcase --keepdb --verbosity=1
Usage: manage.py [options]

manage.py: error: no such option: --keepdb

Calling the same command with some other options, e.g. -q or --failfast works fine. On the other hand, some other listed options such as --no-color fail in a similar manner.

Am I missing something here? How can I pass these options to the command?


Solution

  • I had a similar problem, and issue was having the TEST_RUNNER set to django_nose in the project settings. So in ../settings/local.py, commenting out or removing this:

    TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

    allows the --keepdb switch to be used.