Remove recorded test migrations before test runs.
Review Request #10575 — Created June 3, 2019 and submitted
Django's list of applied migrations persist between individual unit
tests, which causes state leakage issues, breaking some tests that are
sensitive to the migration history.
This change introduces a new
MigrationsTestsMixinclass, which handles
removing the list of applied test migrations before running a test. It
makes use of a new
unrecord_applied_migrations, which can unrecord
specific migration names or all for an app.
To improve performance, both
unrecord_applied_migrationsnow operate on the
queryset, rather than using the utility functions, so that we can
manipulate more than one entry in one operation instead of several.
Unit tests pass on all supported versions of Django.