Fix a regression with running selective unit tests.

Review Request #11345 — Created Dec. 23, 2020 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

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

Changes between revision 1 and 2

orig
1
2

Commits

Summary ID Author
Fix a regression with running selective unit tests.
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 the `Tool` 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()`.
b767c5bc5ef4d4379beb461de70a6712f399bf11 Christian Hammond
Fix a regression with running selective unit tests.
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 the `Tool` 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()`.
2de9792cfbdde396ca08f79ec3b2d5a859677af8 Christian Hammond
reviewboard/testing/testcase.py
Loading...