Opened 13 years ago

Closed 13 years ago

Last modified 9 years ago

#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 Erin Kelly, 13 years ago

Version: 1.2SVN

comment:2 by Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Erin Kelly, 13 years ago

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.

comment:4 by Luke Plant, 13 years ago

Type: Bug

comment:5 by Luke Plant, 13 years ago

Severity: Normal

comment:6 by Erin Kelly, 13 years ago

Resolution: fixed
Status: newclosed

In [16027]:

Fixed #15573: Forced the default site id to be 1 when creating test databases, to prevent a large number of errors when running the tests using the oracle backend.

comment:7 by Erin Kelly, 13 years ago

In [16028]:

[1.3.X] Fixed #15573: Forced the default site id to be 1 when creating
test databases, to prevent a large number of errors when running the
tests using the oracle backend. Backport of r16027 from trunk.

comment:8 by Carl Meyer, 13 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?

comment:9 by Erin Kelly, 13 years ago

In [16062]:

[1.3.X] Refs #15573, #15850: Added a check for whether the sites app is installed when creating the test database, in order to work around a bug in get_model. Thanks to adsva and carljm.

comment:6 by Carl Meyer, 12 years ago

In [16868]:

Fixed #16353 -- don't try to create Site objects on all databases. Refs #15573, #15346. Thanks Aymeric Augustin for the report and the patch.

comment:11 by Carl Meyer, 12 years ago

In [16869]:

[1.3.X] Fixed #16353 -- don't try to create Site objects on all databases. Refs #15573, #15346. Thanks Aymeric Augustin for the report and the patch.

Backport of r16868 in trunk.

comment:12 by Tim Graham <timograham@…>, 9 years ago

In 1f98ec2e53e4636863396ab54f671f4546f9ba4c:

Fixed #23929 -- Added more tests for create_default_site.

Refs: #15346, #15573, #16353, #16828.

Note: See TracTickets for help on using tickets.
Back to Top