Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#19903 closed Bug (fixed)

Exception in servers tests tear down

Reported by: aaugustin Owned by: nobody
Component: Testing framework Version: master
Severity: Normal Keywords:
Cc: carljm, apollo13 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 claudep 3 years ago.
Balanced setUpClass and tearDownClass

Download all attachments as: .zip

Change History (6)

comment:1 Changed 3 years ago by claudep

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.

Changed 3 years ago by claudep

Balanced setUpClass and tearDownClass

comment:2 Changed 3 years ago by claudep

  • Has patch set

comment:3 Changed 3 years ago by aaugustin

  • Triage Stage changed from Accepted to Ready for checkin

Looks reasonable.

comment:4 Changed 3 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 6d52bcbb7cb962e4874a8e7a3d1d8ee77233cd19:

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

comment:5 Changed 3 years ago by Claude Paroz <claude@…>

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