django1/django/test
Aymeric Augustin 5a6f12182e Fixed #20636 -- Stopped stuffing values in the settings.
In Django < 1.6, override_settings restores the settings module that was
active when the override_settings call was executed, not when it was
run. This can make a difference when override_settings is applied to a
class, since it's executed when the module is imported, not when the
test case is run.

In addition, if the settings module for tests is stored alongside the
tests themselves, importing the settings module can trigger an import
of the tests. Since the settings module isn't fully imported yet,
class-level override_settings statements may store a reference to an
incorrect settings module. Eventually this will result in a crash during
test teardown because the settings module restored by override_settings
won't the one that was active during test setup.

While Django should prevent this situation in the future by failing
loudly in such dubious import sequences, that change won't be backported
to 1.5 and 1.4. However, these versions received the "allowed hosts"
patch and they're prone to "AttributeError: 'Settings' object has no
attribute '_original_allowed_hosts'". To mitigate this regression, this
commits stuffs _original_allowed_hosts on a random module instead of the
settings module.

This problem shouldn't occur in Django 1.6, see #20290, but this patch
will be forward-ported for extra safety.

Also tweaked backup variable names for consistency.

Forward port of 0261922 from stable/1.5.x.

Conflicts:
	django/test/utils.py
2013-06-24 20:43:44 +02:00
..
__init__.py Fixed #3011 -- Added swappable auth.User models. 2012-09-26 18:48:09 +08:00
_doctest.py Fixed #17365, #17366, #18727 -- Switched to discovery test runner. 2013-05-10 23:08:45 -04:00
client.py Merge pull request #1270 from tomchristie/remove-incorrect-content-type-test-client 2013-06-14 01:49:33 -07:00
html.py Fixed spelling errors 2013-03-28 11:16:53 -06:00
runner.py Fixed #17365, #17366, #18727 -- Switched to discovery test runner. 2013-05-10 23:08:45 -04:00
signals.py Fixed #17744 -- Reset default file storage with setting_changed signal 2012-10-30 22:23:28 +01:00
simple.py Fixed #20503 - Moved doctest utilities in with the rest of the deprecated test code. 2013-05-27 14:55:08 -06:00
testcases.py Fixed #20579 -- Improved TransactionTestCase.available_apps. 2013-06-12 20:01:41 +02:00
utils.py Fixed #20636 -- Stopped stuffing values in the settings. 2013-06-24 20:43:44 +02:00