Ticket #1090 (closed defect: invalid)
tests fail with KeyError: 'default'
| Reported by: | Ian Delaney <della5@…> | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | migrations | Version: | 0.7.5 |
| Keywords: | test | Cc: |
Description
doing a version bump to 0.7.5. It appears the tests are not able to be run perhaps until installed.
- Testing of dev-python/south-0.7.5 with CPython 2.7...
/mnt/gen2/TmpDir/portage/dev-python/south-0.7.5/work/andrewgodwin-south-3f6f2066c47c/build-2.7/lib /mnt/gen2/TmpDir/portage/dev-python/south-0.7.5/work/andrewgodwin-south-3f6f2066c47c
Traceback (most recent call last):
File "south/tests/autodetection.py", line 3, in <module>
from south.creator.changes import AutoChanges?, InitialChanges?
File "/mnt/gen2/TmpDir/portage/dev-python/south-0.7.5/work/andrewgodwin-south-3f6f2066c47c/build-2.7/lib/south/creator/changes.py", line 10, in <module>
from south.creator.freezer import remove_useless_attributes, freeze_apps, model_key
File "/mnt/gen2/TmpDir/portage/dev-python/south-0.7.5/work/andrewgodwin-south-3f6f2066c47c/build-2.7/lib/south/creator/freezer.py", line 11, in <module>
from south.orm import FakeORM
File "/mnt/gen2/TmpDir/portage/dev-python/south-0.7.5/work/andrewgodwin-south-3f6f2066c47c/build-2.7/lib/south/orm.py", line 12, in <module>
from south.db import db
File "/mnt/gen2/TmpDir/portage/dev-python/south-0.7.5/work/andrewgodwin-south-3f6f2066c47c/build-2.7/lib/south/db/init.py", line 78, in <module>
db = dbs[DEFAULT_DB_ALIAS]
KeyError?: 'default'
Now I'm no south expert but I have touched on several django related packages and got the test suites to run. I cannot figure what is going on from the documented help. From docs/unittests.rst;
If you want the test runner to use syncdb instead of migrate - for example, if
your migrations are taking way too long to apply - simply set
SOUTH_TESTS_MIGRATE = False in settings.py.
You can also set SKIP_SOUTH_TESTS=True in settings.py
Well excuse my confusion but which settings.py where? There is no such settings.py in the source. The installed is in
/usr/lib64/python2.7/site-packages/django/conf/project_template/project_name/settings.py
with 2 folders between conf & settings.py. Do you need to make 1?
The django tool to run tests is a manage.py, but from the packages I have dealt with it's not an installed manage.py but one made for the 'project'. There is again no manage.py. The tests are there but I can't run them as they appear to be missing something. I cannot fathom that you need to edit an installed settings.py file to run a south test suite, it doesn't make sense.

South's tests are designed to be run only inside a pre-existing Django project - they won't work standalone. All you need to do is get a working Django project, add south to INSTALLED_APPS, set SKIP_SOUTH_TESTS=False in the project's settings, and then run ./manage.py test south from the project.
This is unfortunately the only way it can work due to the way the test suite interacts with Django and the application backends.