Don't reload settings in rb-site upgrade during unit tests.
Review Request #11436 — Created Feb. 8, 2021 and submitted
rb-site upgradedetermines it needs to update settings, it first
writes a new
settings_local.pyfile 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_localmodule 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
wrapping a test version of
settings_local.py. 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
settings_localin 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.