Add a TestCase utility function for overriding siteconfig settings.

Review Request #9941 — Created May 15, 2018 and submitted

Information

Djblets
release-1.0.x
f4fd611...

Reviewers

This adds TestCase.siteconfig_settings, a context manager that
overrides the site configuration settings for a test or part of a test.

The base implementation will store new settings in siteconfig and then
revert them after the context manager is finished. It does not apply any
settings to Django by default, though, leaving this up to a more
specific implementation.

This is largely pulled from a utility method in Review Board.

Made use of this in upcoming changes. Verified the new siteconfig settings
and that they were reverted after the change.

Description From Last Updated

I have a very similar implementation in reviewboard.testing.testcases (override_siteconfig). Can you add a cleanup task for me to deprecate that? …

daviddavid
david
  1. 
      
  2. Show all issues

    I have a very similar implementation in reviewboard.testing.testcases (override_siteconfig). Can you add a cleanup task for me to deprecate that?

    Also, how would you feel about using that name? It makes it more consistent with django's override_settings.

    1. I can considered this, but override_settings is a decorator that can be applied to a test class or function as a whole, whereas self.settings is the Django TestCase equivalent of this new function. I decided to keep consistent with that naming.

      I'll file the task.

  3. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-1.0.x (53fb997)