#16828: Upgrade from 1.3 to 1.3.1 breaks manage.py test with multiple databases
---------------------------+---------------------------------------------
Reporter: aaugustin | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: Testing framework
Version: 1.3 | Severity: Release blocker
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------
To reproduce this problem:
* `django-admin.py startproject regrtest && cd regrtest`
* create a file called `routers.py` with this content (this is a dummy
router that puts everything in the "default" database):
{{{
class TestRouter(object):
def db_for_read(self, model, **hints):
return 'default'
def db_for_write(self, model, **hints):
return 'default'
def allow_relation(self, obj1, obj2, **hints):
return True
def allow_syncdb(self, db, model):
return db == 'default'
}}}
* in `settings.py`, replace the default value of `DATABASES` with this
content:
{{{
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'default.sqlite3',
},
'other': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'other.sqlite3',
},
}
DATABASE_ROUTERS = ['routers.TestRouter']
}}}
* `python manage.py test auth` works under 1.3 but not under 1.3.1:
{{{
aaugustin@aaugustin regrtest % . ../dj13_venv/bin/activate
(dj13_venv)aaugustin@aaugustin regrtest % python manage.py test auth
Creating test database for alias 'default'...
Creating test database for alias 'other'...
..................................................................................................
----------------------------------------------------------------------
Ran 98 tests in 1.745s
OK
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
(dj13_venv)aaugustin@aaugustin regrtest % . ../dj131_venv/bin/activate
(dj131_venv)aaugustin@aaugustin regrtest % python manage.py test auth
Creating test database for alias 'default'...
Creating test database for alias 'other'...
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/core/management/commands/test.py", line 37, in handle
failures = test_runner.run_tests(test_labels)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/test/simple.py", line 359, in run_tests
old_config = self.setup_databases()
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/test/simple.py", line 296, in setup_databases
test_db_name = connection.creation.create_test_db(self.verbosity,
autoclobber=not self.interactive)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/db/backends/creation.py", line 384, in create_test_db
if Site is not None and
Site.objects.using(self.connection.alias).count() == 1:
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/db/models/query.py", line 334, in count
return self.query.get_count(using=self.db)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/db/models/sql/query.py", line 401, in get_count
number = obj.get_aggregation(using=using)[None]
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/db/models/sql/query.py", line 367, in get_aggregation
result = query.get_compiler(using).execute_sql(SINGLE)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/Users/aaugustin/Documents/dev/dj131_venv/lib/python2.6/site-
packages/django/db/backends/sqlite3/base.py", line 234, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: django_site
}}}
Apparently, the origin of the problem is that Django attempts to create a
default site object in the "other" database.
----
NB: for this test, I created two virtualenvs, `dj13_venv` and
`dj131_venv`, with a fresh copy of Django 1.3 and 1.3.1 respectively:
{{{
aaugustin@aaugustin dev % virtualenv-2.6 --no-site-packages dj13_venv
New python executable in dj13_venv/bin/python
Installing setuptools............done.
Installing pip...............done.
aaugustin@aaugustin dev % . ./dj13_venv/bin/activate
(dj13_venv)aaugustin@aaugustin dev % pip install django==1.3
Downloading/unpacking django==1.3
Downloading Django-1.3.tar.gz (6.5Mb): 6.5Mb downloaded
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.6/django-admin.py from 644 to 755
changing mode of /Users/aaugustin/Documents/dev/dj13_venv/bin/django-
admin.py to 755
Successfully installed django
Cleaning up...
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/16828>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.