Fix a regression with running selective unit tests.
Review Request #11345 — Created Dec. 23, 2020 and submitted
The recent change to fix the
SiteConfigurationchanges on version-only
upgrades broke running selective unit tests. This happened because the
test runner, which normally emits post-migrate signals on database
setup, no longer had a way to set up the configuration, or the tools
entries for that matter.
We now initialize the site configuration after Django sets up the
database in the test runner, so that we can have the correct state.
Note that we cannot call
finalize_setup(), as we'll still end up with
some state (logging state, at the very least) that's set up wrong, due
due to the
Toolimport process. This is worth digging into later, but
it wasn't trivial to work around without possibly regressing something
else in this change.
It does, however, set some default state we use for all unit tests
before any transactions begin, to avoid a database write in each test's
The entire test suite, and various partial test runs, all run succesfully.
F401 'reviewboard.admin.management.sites.init_siteconfig' imported but unused
Removed an unused import.
Revision 2 (+56 -8)
Checks run (2 succeeded)