#16574 closed Bug (fixed)
Test fails when setting MESSAGE_TAGS
| Reported by: | Manuel Strehl | Owned by: | elbarto |
|---|---|---|---|
| Component: | contrib.messages | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
in a fresh Django 1.3 project (directly after django_admin
startproject) I set this in the settings.py:
MESSAGE_TAGS = {
40: "ui-state-error", # ERROR
30: "ui-state-highlight", # WARNING
20: "ui-state-info", # INFO
25: "ui-state-success", # SUCCESS
}
which causes a test failure in
django.contrib.messages.tests.cookie.CookieTest.test_tags.
As far as I can see, I did everything the way the docs say.
Corresponding list message: http://groups.google.com/group/django-developers/browse_thread/thread/4ab6ef2eedd4bfbe
Attachments (3)
Change History (15)
comment:1 by , 14 years ago
| Easy pickings: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
| Owner: | changed from to |
|---|
by , 14 years ago
| Attachment: | message_tests.diff added |
|---|
comment:3 by , 14 years ago
With this patch it passes the tests:
bsanchez@bsanchez:~/test/testproject$ python manage.py test messages Creating test database for alias 'default'... ........................................................................ ---------------------------------------------------------------------- Ran 72 tests in 0.478s OK Destroying test database for alias 'default'... bsanchez@bsanchez:~/test/testproject$
On the other hand, I set the decorator in the class instead of the method because it fails there:
bsanchez@bsanchez:~/test/testproject$ python manage.py test messages
Creating test database for alias 'default'...
......................F.................................................
======================================================================
FAIL: test_tags (django.contrib.messages.tests.cookie.CookieTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bsanchez/src/trunk/django/test/utils.py", line 214, in inner
return test_func(*args, **kwargs)
File "/home/bsanchez/src/trunk/django/contrib/messages/tests/base.py", line 372, in test_tags
'success'])
AssertionError: Lists differ: [u'info', '', u'extra-tag debu... != ['info', '', 'extra-tag debug'...
First differing element 4:
ui-state-error
error
- [u'info', '', u'extra-tag debug', u'warning', u'ui-state-error', u'success']
? - - - - --------- -
+ ['info', '', 'extra-tag debug', 'warning', 'error', 'success']
----------------------------------------------------------------------
Ran 72 tests in 0.467s
FAILED (failures=1)
Destroying test database for alias 'default'...
bsanchez@bsanchez:~/test/testproject$
comment:4 by , 14 years ago
| Has patch: | set |
|---|
comment:5 by , 14 years ago
Just added a patch that uses override_settings throughout the contrib.messages tests.
comment:6 by , 14 years ago
| Patch needs improvement: | set |
|---|
Thanks, the patch is generally looking good. However, I'm now getting 3 failures. Am I missing something?
python manage.py test messages
Creating test database for alias 'default'...
......................F..........................F...................F..
======================================================================
FAIL: test_tags (django.contrib.messages.tests.cookie.CookieTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/julien/Documents/Development/eclipse/workspace/DjangoCore/git/django/contrib/messages/tests/base.py", line 339, in test_tags
'success'])
AssertionError: Lists differ: [u'info', '', u'extra-tag debu... != ['info', '', 'extra-tag debug'...
First differing element 4:
ui-state-error
error
- [u'info', '', u'extra-tag debug', u'warning', u'ui-state-error', u'success']
? - - - - --------- -
+ ['info', '', 'extra-tag debug', 'warning', 'error', 'success']
======================================================================
FAIL: test_tags (django.contrib.messages.tests.fallback.FallbackTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/julien/Documents/Development/eclipse/workspace/DjangoCore/git/django/contrib/messages/tests/base.py", line 339, in test_tags
'success'])
AssertionError: Lists differ: [u'info', '', u'extra-tag debu... != ['info', '', 'extra-tag debug'...
First differing element 4:
ui-state-error
error
- [u'info', '', u'extra-tag debug', u'warning', u'ui-state-error', u'success']
? - - - - --------- -
+ ['info', '', 'extra-tag debug', 'warning', 'error', 'success']
======================================================================
FAIL: test_tags (django.contrib.messages.tests.session.SessionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/julien/Documents/Development/eclipse/workspace/DjangoCore/git/django/contrib/messages/tests/base.py", line 339, in test_tags
'success'])
AssertionError: Lists differ: [u'info', '', u'extra-tag debu... != ['info', '', 'extra-tag debug'...
First differing element 4:
ui-state-error
error
- [u'info', '', u'extra-tag debug', u'warning', u'ui-state-error', u'success']
? - - - - --------- -
+ ['info', '', 'extra-tag debug', 'warning', 'error', 'success']
----------------------------------------------------------------------
Ran 72 tests in 0.937s
FAILED (failures=3)
Destroying test database for alias 'default'...
comment:8 by , 14 years ago
Sorry, forgot my comment above. Of course, the problem is with base.LEVEL_TAGS. Will work on a new patch.
It should be pretty easy to fix the tests with @override_settings.