Save and restore siteconfig settings for all unit tests.

Review Request #10478 — Created March 31, 2019 and submitted

Information

Review Board
release-4.0.x

Reviewers

We had a number of siteconfig settings leaks between tests, caused by
one test modifying the settings and another utilizing those settings.
This could subtly impact some tests in ways that weren't always clear,
and it could depend on the order in which tests were run or the order in
which events happened. This largely happens because we don't necessarily
fully replace the SiteConfiguration in-between tests, instead often
using a cached copy.

This change updates all individual tests that need to modify siteconfig
to use the siteconfig_settings context manager, which will handle
setting and restoring the settings.

Classes that modify these settings in setUp now ensure they've cleaned
up after themselves in tearDown, preventing further leaks. Some do
this by saving and restoring an individual setting that's modified, and
others save a copy of all settings and restore them, depending on the
needs of the test suite.

Room for improvement going forward would be to add formal support in our
TestCase to let classes define global siteconfig settings and handle
the setting and restoring automatically, to completely remove the need
for custom management of siteconfig, but that's outside the scope of
this change.

All unit tests pass.

Summary ID
Save and restore siteconfig settings for all vunit tests.
We had a number of siteconfig settings leaks between tests, caused by one test modifying the settings and another utilizing those settings. This could subtly impact some tests in ways that weren't always clear, and it could depend on the order in which tests were run or the order in which events happened. This largely happens because we don't necessarily fully replace the `SiteConfiguration` in-between tests, instead often using a cached copy. This change updates all individual tests that need to modify siteconfig to use the `siteconfig_settings` context manager, which will handle setting and restoring the settings. Classes that modify these settings in `setUp` now ensure they've cleaned up after themselves in `tearDown`, preventing further leaks. Some do this by saving and restoring an individual setting that's modified, and others save a copy of all settings and restore them, depending on the needs of the test suite. Room for improvement going forward would be to add formal support in our `TestCase` to let classes define global siteconfig settings and handle the setting and restoring automatically, to completely remove the need for custom management of siteconfig, but that's outside the scope of this change.
a31b6b1ec0ab6e806e5a4462f1c7b772f5628c10
Description From Last Updated

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.0.x (dcaf477)