Exception in servers tests tear down
This is reproducible:
% PYTHONPATH=.. python3.3 ./runtests.py --settings=test_sqlite servers
Creating test database for alias 'default'...
Creating test database for alias 'other'...
........
----------------------------------------------------------------------
Ran 8 tests in 1.327s
OK
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
Traceback (most recent call last):
File "./runtests.py", line 331, in <module>
options.failfast, args)
File "./runtests.py", line 166, in django_tests
failures = test_runner.run_tests(test_labels, extra_tests=extra_tests)
File "/Users/myk/Documents/dev/django/django/test/simple.py", line 383, in run_tests
self.teardown_test_environment()
File "/Users/myk/Documents/dev/django/django/test/simple.py", line 342, in teardown_test_environment
teardown_test_environment()
File "/Users/myk/Documents/dev/django/django/test/utils.py", line 103, in teardown_test_environment
del settings._original_allowed_hosts
File "/Users/myk/Documents/dev/django/django/utils/functional.py", line 233, in __delattr__
delattr(self._wrapped, name)
File "/Users/myk/Documents/dev/django/django/conf/__init__.py", line 188, in __delattr__
return super(UserSettingsHolder, self).__delattr__(name)
AttributeError: _original_allowed_hosts
The culprit is the
LiveServerAddress
test case. ParentsetUpClass
is called 8 times (becauseraises_exception
manually calls it), whiletearDownClass
is called only one time. So we have 8settings_override.enable()
balanced by only onesettings_override.disable()
. Consequently, the settings object we get inteardown_test_environment
is one of the overriden settings instance, not the initial one, hence the absence of_original_allowed_hosts
attribute.