Remove recorded test migrations before test runs.
Review Request #10575 — Created June 3, 2019 and submitted — Latest diff uploaded
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
MigrationsTestsMixin
class, which handles
removing the list of applied test migrations before running a test. It
makes use of a newunrecord_applied_migrations
, which can unrecord
specific migration names or all for an app.To improve performance, both
record_applied_migrations
and
unrecord_applied_migrations
now operate on theMigrationRecorder
's
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.