Code

Opened 10 months ago

Closed 5 weeks 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)

./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

Attachments (0)

Change History (4)

comment:1 Changed 10 months ago by apollo13

  • Description modified (diff)

comment:2 Changed 10 months ago by apollo13

  • Description modified (diff)

comment:3 Changed 10 months 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 5 weeks 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.