#32012: Test runner setup_databases crashes with "TEST": {"MIGRATE": False}.
-------------------------------------+-------------------------------------
     Reporter:  Jaap Roes            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Testing framework    |                  Version:  3.1
     Severity:  Release blocker      |               Resolution:
     Keywords:  testrunner crash     |             Triage Stage:  Accepted
  setup database migrations          |
  disabled                           |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by felixxm):

 Mocking `settings.MIGRATION_MODULES` to `None` for all apps sounds like an
 easier fix, see draft below:
 {{{
 diff --git a/django/db/backends/base/creation.py
 b/django/db/backends/base/creation.py
 index 503f7f56fd..3c0338d359 100644
 --- a/django/db/backends/base/creation.py
 +++ b/django/db/backends/base/creation.py
 @@ -69,6 +69,22 @@ class BaseDatabaseCreation:
                  database=self.connection.alias,
                  run_syncdb=True,
              )
 +        else:
 +            try:
 +                old = settings.MIGRATION_MODULES
 +                settings.MIGRATION_MODULES = {
 +                    app.label: None
 +                    for app in apps.get_app_configs()
 +                }
 +                call_command(
 +                    'migrate',
 +                    verbosity=max(verbosity - 1, 0),
 +                    interactive=False,
 +                    database=self.connection.alias,
 +                    run_syncdb=True,
 +                )
 +            finally:
 +                settings.MIGRATION_MODULES = old

          # We then serialize the current state of the database into a
 string
          # and store it on the connection. This slightly horrific process
 is so people
 }}}
 but I'm not convinced.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.c394041b0145f4cc932e7e658bd88b64%40djangoproject.com.

Reply via email to