Don't reload settings in rb-site upgrade during unit tests.

Review Request #11436 — Created Feb. 8, 2021 and submitted

Review Board

When rb-site upgrade determines it needs to update settings, it first
writes a new file and then reloads Django's internal

The way it reloaded settings wasn't very safe, and that's been fixed up,
but the entire block of logic for reloading settings is problematic in
unit tests. While the unit tests for settings migration work fine, they
impact other unit tests. This happens by removing the cached
settings_local module in Python and then immediately triggering a

Since the unit tests are working with test versions of this file, what
we end up doing is finishing the test suite with django.conf.settings
wrapping a test version of Future unit tests are
then sensitive to this, and blow up.

The code has been updated to only perform a settings reload if we know
that the settings_local in cache is the same one containing settings
we're migrating. This will be true when running rb-site upgrade, but
won't be when performing unit tests.

All unit tests that failed due to this issue now pass.

Don't reload settings in rb-site upgrade during unit tests.
  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (61951da)