Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#19903 closed Bug (fixed)

Exception in servers tests tear down

Reported by: Aymeric Augustin Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Carl Meyer, Florian Apolloner Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Attachments (1)

19903-1.diff (581 bytes ) - added by Claude Paroz 11 years ago.
Balanced setUpClass and tearDownClass

Download all attachments as: .zip

Change History (6)

comment:1 by Claude Paroz, 11 years ago

The culprit is the LiveServerAddress test case. Parent setUpClass is called 8 times (because raises_exception manually calls it), while tearDownClass is called only one time. So we have 8 settings_override.enable() balanced by only one settings_override.disable(). Consequently, the settings object we get in teardown_test_environment is one of the overriden settings instance, not the initial one, hence the absence of _original_allowed_hosts attribute.

by Claude Paroz, 11 years ago

Attachment: 19903-1.diff added

Balanced setUpClass and tearDownClass

comment:2 by Claude Paroz, 11 years ago

Has patch: set

comment:3 by Aymeric Augustin, 11 years ago

Triage Stage: AcceptedReady for checkin

Looks reasonable.

comment:4 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 6d52bcbb7cb962e4874a8e7a3d1d8ee77233cd19:

Fixed #19903 -- Fixed unbalanced setUp/tearDown calls in LiveServerAddress test

comment:5 by Claude Paroz <claude@…>, 11 years ago

In cf114cffea5482a32064de86c61417d511c2edca:

[1.5.x] Fixed #19903 -- Fixed unbalanced setUp/tearDown calls in LiveServerAddress test

Backport of 6d52bcbb7c from master.

Note: See TracTickets for help on using tickets.
Back to Top