Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#15850 closed Bug (fixed)

Test runner fails when sites app not installed

Reported by: adsva Owned by: Carl Meyer
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: schmilblick Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I don't have 'sites' in INSTALLED_APPS, and Changeset [16028] seems to break the test runner.

Selected bits from the manage.py test traceback:

Traceback (most recent call last):

  ...

  File ".../django/db/backends/creation.py", line 256, in create_test_db
    if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
  File ".../django/db/models/query.py", line 334, in count
    return self.query.get_count(using=self.db)
  File ".../django/db/models/sql/query.py", line 401, in get_count
    number = obj.get_aggregation(using=using)[None]
  File ".../django/db/models/sql/query.py", line 367, in get_aggregation
    result = query.get_compiler(using).execute_sql(SINGLE)
  File ".../django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File ".../django/db/backends/sqlite3/base.py", line 226, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: django_site

I'm wondering if Site = get_model('sites', 'Site') is really a good way to check if the sites is installed. Looks like as soon as the Sites model is declared it registers itself to be discovered by get_model?

Change History (6)

comment:1 by schmilblick, 14 years ago

Cc: schmilblick added

comment:2 by Carl Meyer, 14 years ago

Owner: changed from nobody to Carl Meyer
Status: newassigned
Triage Stage: UnreviewedAccepted

Yes, I am seeing this problem as well. #15866 is the root cause, so my first approach is going to be fixing that.

Not closing this as duplicate, though, because it would be possible to fix this (by changing r16027) if fixing #15866 turns out to be quite difficult.

comment:3 by Carl Meyer, 14 years ago

Resolution: fixed
Status: assignedclosed

In [16053]:

(The changeset message doesn't reference this ticket)

comment:4 by Carl Meyer, 14 years ago

Easy pickings: unset

This also needs to be fixed in 1.3.X. Backporting the fix for #15866 is not acceptable as a solution, because #15866 is not a regression and the fix is backwards-incompatible (albeit only to private internal API). I've proposed at http://code.djangoproject.com/ticket/15573#comment:8 that the best answer would be to modify the fix for #15573 to check INSTALLED_APPS rather than the return value of get_model - but I'd prefer if someone with access to test on Oracle would make that change.

comment:5 by Erin Kelly, 14 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 Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In 9f13c3328199d2fa70235cdc63bb06b1efc5b117:

Removed the only_installed argument of Apps.get_models.

Refs #15903, #15866, #15850.

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