4

With Django 1.4.5, I'm using django-nose 1.1.0.

I have two settings files with no diff.

-> % diff local_settings.py test_settings/sqlite.py

I run the tests with:

-> % python manage.py test foo --settings=local_settings

and I get

Ran 91 tests in 5.273s
OK (SKIP=6)

Running the same identical settings from the different location

-> % python manage.py test foo --settings=test_settings.sqlite

The tests bail without all running:

Ran 43 tests in 1.230s
FAILED (errors=1)

I get a traceback, DatabaseError: no such table: django_content_type The traceback comes through the loading of the urls. Something that gets instantiated there calls ContentType.objects.get_for_model(self.model). How is this difference possible when the settings are identical?

My manage.py file is generic:

#!/usr/bin/env python

from django.core import management

if __name__ == "__main__":
    management.execute_from_command_line()
Skylar Saveland
  • 11,116
  • 9
  • 75
  • 91
  • 1
    What happens if you move `local_settings` under `test_settings` package and run tests again with `--settings=test_settings.local_settings`? Also, please, check if there is anything in `test_settings/__init__.py`. – alecxe Apr 16 '13 at 14:34
  • same, nothing in `__init__.py` – Skylar Saveland Apr 16 '13 at 20:59
  • Ideally it'll be great to see what is in your identical settings files. – alecxe Apr 23 '13 at 20:48

1 Answers1

1

Is your database NAME set to a relative path for the sqlite DB?

If so, you may simply need to syncdb with your settings file in test_settings.

DatabaseError: no such table: django_content_type means one of the django specific tables isn't found, which sounds like an issue with the DB itself, not your app or the settings file itself.

jlovison
  • 1,126
  • 1
  • 10
  • 12
  • What happens if you run `python manage.py syncdb --settings=test_settings.sqlite` and then run the test command again? – jlovison Apr 24 '13 at 09:47