Opened 11 years ago

Closed 10 years ago

#21148 closed Bug (fixed)

Test isolation errors on master.

Reported by: Florian Apolloner Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: app-refactor, app, refactor
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Florian Apolloner)

./runtests.py select_for_update swappable_models --settings=test_sqlite
Creating test database for alias 'default'...
Creating test database for alias 'other'...
.Essssssss
======================================================================
ERROR: test_generated_data (swappable_models.tests.SwappableModelTests)
Permissions and content types are not created for a swapped model
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/florian/sources/django.git/django/test/utils.py", line 220, in inner
    return test_func(*args, **kwargs)
  File "/home/florian/sources/django.git/tests/swappable_models/tests.py", line 39, in test_generated_data
    ContentType.objects.filter(app_label='swappable_models').delete()
  File "/home/florian/sources/django.git/django/db/models/query.py", line 558, in delete
    collector.delete()
  File "/home/florian/sources/django.git/django/db/models/deletion.py", line 262, in delete
    qs._raw_delete(using=self.using)
  File "/home/florian/sources/django.git/django/db/models/query.py", line 570, in _raw_delete
    sql.DeleteQuery(self.model).delete_qs(self, using)
  File "/home/florian/sources/django.git/django/db/models/sql/subqueries.py", line 86, in delete_qs
    self.get_compiler(using).execute_sql(None)
  File "/home/florian/sources/django.git/django/db/models/sql/compiler.py", line 763, in execute_sql
    cursor.execute(sql, params)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/backends/sqlite3/base.py", line 476, in execute
    return Database.Cursor.execute(self, query, params)
OperationalError: no such table: multiple_database_review

----------------------------------------------------------------------
Ran 10 tests in 0.046s

FAILED (errors=1, skipped=8)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

This is caused by #15903 -- I don't see an obvious fix though, some stuff requires all models to be registered (tests come to mind where you change INSTALLED_APPS on demand, but the related cache is only filled once) while other stuff (like the collector) should never see models from not installed applications.

This specific failure doesn't show up if you run the whole testsuite or

./runtests.py select_for_update swappable_models multiple_database

Change History (4)

comment:1 by Florian Apolloner, 11 years ago

Description: modified (diff)

comment:2 by Florian Apolloner, 11 years ago

Description: modified (diff)

comment:3 by Florian Apolloner <florian@…>, 11 years ago

In 16ceb05b4751425ed16ee0eddd0c533f067344b2:

Isolated select_for_update tests a bit more.

This change prevents including the multiple_database test models without
duplicating the router code (we probably should do this at one point).

Refs #21148

comment:4 by Aymeric Augustin, 10 years ago

Resolution: fixed
Status: newclosed

The failure described in this ticket doesn't happen anymore, maybe as a side effect of app-loading.

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