Fix a regression with running selective unit tests.
Review Request #11345 — Created Dec. 23, 2020 and submitted — Latest diff uploaded
The recent change to fix the
SiteConfiguration
changes 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 theTool
import 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
setUp()
.
The entire test suite, and various partial test runs, all run succesfully.