Opened 3 years ago

Closed 2 years ago

#21148 closed Bug (fixed)

Test isolation errors on master.

Reported by: apollo13 Owned by: nobody
Component: Database layer (models, ORM) Version: master
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 apollo13)

./ select_for_update swappable_models --settings=test_sqlite
Creating test database for alias 'default'...
Creating test database for alias 'other'...
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/", line 220, in inner
    return test_func(*args, **kwargs)
  File "/home/florian/sources/django.git/tests/swappable_models/", line 39, in test_generated_data
  File "/home/florian/sources/django.git/django/db/models/", line 558, in delete
  File "/home/florian/sources/django.git/django/db/models/", line 262, in delete
  File "/home/florian/sources/django.git/django/db/models/", line 570, in _raw_delete
    sql.DeleteQuery(self.model).delete_qs(self, using)
  File "/home/florian/sources/django.git/django/db/models/sql/", line 86, in delete_qs
  File "/home/florian/sources/django.git/django/db/models/sql/", line 763, in execute_sql
    cursor.execute(sql, params)
  File "/home/florian/sources/django.git/django/db/", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/florian/sources/django.git/django/db/", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/backends/sqlite3/", 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

./ select_for_update swappable_models multiple_database

Change History (4)

comment:1 Changed 3 years ago by apollo13

  • Description modified (diff)

comment:2 Changed 3 years ago by apollo13

  • Description modified (diff)

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

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 Changed 2 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

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