[Django] #31413: LoaderTests not isolated on databases that don't support transactions

40 views
Skip to first unread message

Django

unread,
Mar 31, 2020, 7:04:58 PM3/31/20
to django-...@googlegroups.com
#31413: LoaderTests not isolated on databases that don't support transactions
--------------------------------------+------------------------
Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
On databases that don't support transactions, the changes that each test
in `migrations.test_loader.LoaderTests` makes to the `django_migrations`
table isn't rolled back after each test, resulting in this failure:

{{{
======================================================================
FAIL: test_loading_squashed (migrations.test_loader.LoaderTests)
Tests loading a squashed migration
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/test/utils.py", line 373, in inner
return func(*args, **kwargs)
File "/home/tim/code/django/tests/migrations/test_loader.py", line 255,
in test_loading_squashed
2,
AssertionError: 1 != 2
}}}
For example, to make `test_check_consistent_history` clean up after itself
(this doesn't solve the issue as there are more tests that would need
similar changes):
{{{ #!diff
diff --git a/tests/migrations/test_loader.py
b/tests/migrations/test_loader.py
index e3a635dc63..2b8f155c72 100644
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -415,6 +415,7 @@ class LoaderTests(TestCase):
)
with self.assertRaisesMessage(InconsistentMigrationHistory, msg):
loader.check_consistent_history(connection)
+ recorder.record_unapplied('migrations', '0002_second')

@override_settings(
MIGRATION_MODULES={'migrations':
'migrations.test_migrations_squashed_extra'},
}}}
There might be a better solution.

--
Ticket URL: <https://code.djangoproject.com/ticket/31413>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 1, 2020, 12:58:31 AM4/1/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+------------------------------------

Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by felixxm):

* stage: Unreviewed => Accepted


Comment:

I confirmed that two tests in `migrations.test_loader` fail on databases
that don't support transactions:


{{{
======================================================================
FAIL: test_loading_squashed (migrations.test_loader.LoaderTests)
Tests loading a squashed migration
----------------------------------------------------------------------
Traceback (most recent call last):

File "/home/felixx/repo/django/django/test/utils.py", line 381, in inner
return func(*args, **kwargs)
File "django/tests/migrations/test_loader.py", line 255, in


test_loading_squashed
2,
AssertionError: 1 != 2

======================================================================
FAIL: test_apply (migrations.test_loader.RecorderTests)


----------------------------------------------------------------------
Traceback (most recent call last):

File "django/tests/migrations/test_loader.py", line 39, in test_apply
set(),
AssertionError: Items in the first set but not the second:
('myapp', '0432_ponies')

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:1>

Django

unread,
Apr 18, 2020, 6:43:57 AM4/18/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+------------------------------------

Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------

Comment (by Sanskar Jaiswal):

I ran all migrations tests on a non-transactional database (MyISAM), and a
total of 13 tests failed in `migrations.test_loader`,
`migrations.test_operations.py`, `migrations.test_executer.py` and
`migrations.test_commands`. Is this behaviour expected?

--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:2>

Django

unread,
Apr 18, 2020, 8:08:09 AM4/18/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+------------------------------------

Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------

Comment (by Tim Graham):

There might be other failures to fix beyond the scope of this ticket.
MyISAM isn't tested on CI.

--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:3>

Django

unread,
Apr 20, 2020, 7:20:42 AM4/20/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+------------------------------------

Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------

Comment (by Sanskar Jaiswal):

The only fix I can think of is manually adding `recorder.record_unapplied`
to all tests which execute `recorder.record_applied`. Does anyone have a
better solution?

--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:4>

Django

unread,
May 2, 2020, 4:14:25 PM5/2/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+------------------------------------

Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------

Comment (by Tim Graham):

How about adding a helper method called `record_applied` that calls
`recorder.record_applied` but also keeps track of the calls so that a
`tearDown` method could call `recorder.record_unapplied` as needed (and
only if transactions aren't supported)?

--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:5>

Django

unread,
Dec 30, 2020, 5:39:12 PM12/30/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+------------------------------------------
Reporter: Tim Graham | Owner: Hasan Ramezani
Type: Bug | Status: assigned
Component: Migrations | Version: 3.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned


Comment:

[https://github.com/django/django/pull/13825 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:6>

Django

unread,
Dec 30, 2020, 5:39:29 PM12/30/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+------------------------------------------
Reporter: Tim Graham | Owner: Hasan Ramezani
Type: Bug | Status: assigned
Component: Migrations | Version: 3.0

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------------
Changes (by Hasan Ramezani):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:7>

Django

unread,
Dec 31, 2020, 2:19:39 AM12/31/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+---------------------------------------------

Reporter: Tim Graham | Owner: Hasan Ramezani
Type: Bug | Status: assigned
Component: Migrations | Version: 3.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:8>

Django

unread,
Dec 31, 2020, 7:17:21 AM12/31/20
to django-...@googlegroups.com
#31413: migrations.test_loader not isolated on databases that don't support
transactions.
----------------------------+---------------------------------------------
Reporter: Tim Graham | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Migrations | Version: 3.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"a2e3f95b0937f3f1e4a479db219392eb6ded39f7" a2e3f95b]:
{{{
#!CommitTicketReference repository=""
revision="a2e3f95b0937f3f1e4a479db219392eb6ded39f7"
Fixed #31413 -- Fixed isolation of migrations.test_loader on databases
that don't support transactions.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31413#comment:9>

Reply all
Reply to author
Forward
0 new messages