mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-05-28 16:38:24 +00:00
Clean up docstring for override_settings
This commit is contained in:
parent
2a1e2d3f68
commit
c1926dc77e
1 changed files with 20 additions and 4 deletions
|
|
@ -20,10 +20,26 @@ class override_settings(object):
|
||||||
"""
|
"""
|
||||||
Temporarily override Django settings.
|
Temporarily override Django settings.
|
||||||
|
|
||||||
Acts as either a decorator, or a context manager. If it's a decorator it
|
Can be used as either a decorator on test classes/functions or as
|
||||||
takes a function and returns a wrapped function. If it's a contextmanager
|
a context manager inside test functions.
|
||||||
it's used with the ``with`` statement. In either event entering/exiting
|
|
||||||
are called before and after, respectively, the function/block is executed.
|
In either case it temporarily overrides django.conf.settings so
|
||||||
|
that you can test how code acts when certain settings are set to
|
||||||
|
certain values or deleted altogether with SETTING_DELETED.
|
||||||
|
|
||||||
|
>>> @override_settings(FOOBAR=42)
|
||||||
|
>>> class TestBaz(TestCase):
|
||||||
|
>>> # settings.FOOBAR == 42 for all tests
|
||||||
|
>>>
|
||||||
|
>>> @override_settings(FOOBAR=43)
|
||||||
|
>>> def test_widget(self):
|
||||||
|
>>> # settings.FOOBAR == 43 for just this test
|
||||||
|
>>>
|
||||||
|
>>> with override_settings(FOOBAR=44):
|
||||||
|
>>> # settings.FOOBAR == 44 just inside this block
|
||||||
|
>>> pass
|
||||||
|
>>>
|
||||||
|
>>> # settings.FOOBAR == 43 inside the test
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.options = kwargs
|
self.options = kwargs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue