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

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

Information

Review Board
release-4.0.x

Reviewers

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

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
reload.

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 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
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.

Commits

Files