#15573 closed Bug (fixed)
runtests.py sets incorrect SITE_ID when using Oracle
Reported by: | Erin Kelly | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | oracle site_id |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Running the test suite under Oracle currently generates a large number of errors that look like this:
====================================================================== ERROR: test_shortcut_view (django.contrib.contenttypes.tests.ContentTypesTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Django\django.trunk\django\contrib\contenttypes\tests.py", line 66, in test_shortcut_view current_site = Site.objects.get_current() File "C:\Django\django.trunk\django\contrib\sites\models.py", line 26, in get_current current_site = self.get(pk=sid) File "C:\Django\django.trunk\django\db\models\manager.py", line 132, in get return self.get_query_set().get(*args, **kwargs) File "C:\Django\django.trunk\django\db\models\query.py", line 349, in get % self.model._meta.object_name) DoesNotExist: Site matching query does not exist. ----------------------------------------------------------------------
This seems to be a result of r14537. Since the test setup does a syncdb followed by a flush on each database, the default Site object gets created twice. Since the sequence reset no longer decreases the sequence value, the second Site object created, the one that sticks around and gets used for the tests, has an id of 2 instead of 1. However, runtests.py forces the SITE_ID setting to be 1.
Change History (12)
comment:1 by , 14 years ago
Version: | 1.2 → SVN |
---|
comment:2 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 14 years ago
comment:4 by , 14 years ago
Type: | → Bug |
---|
comment:5 by , 14 years ago
Severity: | → Normal |
---|
comment:8 by , 14 years ago
Easy pickings: | unset |
---|
This change broke running of tests in a project without contrib.sites installed (#15850), due to the underlying issue #15866. I've fixed #15866 in trunk, but wasn't planning to backport to 1.3.X for stability reasons, since #15866 itself is not a regression and the fix changes the behavior of (internal and undocumented) methods in a backwards-incompatible way.
However, #15850 is a significant regression and still needs fixing in 1.3.X. I think the least-invasive approach there will be to modify the change made in r16028 to check INSTALLED_APPS for django.contrib.sites rather than using the return value of get_model. I don't feel comfortable making that change myself, though, since I don't have Oracle available to ensure that the fix still works for the original purpose.
Ian, would you be able to make that change in 1.3.X?
A related problem occurs elsewhere: the fixtures for the flatpages tests use a hard-coded site id of 1. Maybe the best way to fix this is going to be to find a way to coerce the default site id to be 1 when running the test suite.