Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#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.

http://pastebin.com/DSWdgCEf

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)

message_tests.diff (727 bytes ) - added by elbarto 13 years ago.
16574-2.diff (9.4 KB ) - added by Claude Paroz 13 years ago.
Generalize override_settings
16574-3.diff (10.3 KB ) - added by Claude Paroz 13 years ago.
Fix base.LEVEL_TAGS at override_settings level

Download all attachments as: .zip

Change History (15)

comment:1 by Aymeric Augustin, 13 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

It should be pretty easy to fix the tests with @override_settings.

comment:2 by elbarto, 13 years ago

Owner: changed from nobody to elbarto

by elbarto, 13 years ago

Attachment: message_tests.diff added

comment:3 by elbarto, 13 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 elbarto, 13 years ago

Has patch: set

by Claude Paroz, 13 years ago

Attachment: 16574-2.diff added

Generalize override_settings

comment:5 by Claude Paroz, 13 years ago

Just added a patch that uses override_settings throughout the contrib.messages tests.

comment:6 by Julien Phalip, 13 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:7 by Claude Paroz, 13 years ago

Strange... Julien, where does this 'ui-state-error' comes from?

comment:8 by Claude Paroz, 13 years ago

Sorry, forgot my comment above. Of course, the problem is with base.LEVEL_TAGS. Will work on a new patch.

by Claude Paroz, 13 years ago

Attachment: 16574-3.diff added

Fix base.LEVEL_TAGS at override_settings level

comment:9 by Claude Paroz, 13 years ago

Patch needs improvement: unset

Tests should pass now.

comment:10 by Julien Phalip, 13 years ago

Triage Stage: AcceptedReady for checkin

Great, thanks Claude!

comment:11 by Julien Phalip, 13 years ago

Resolution: fixed
Status: newclosed

In [17027]:

Fixed #16574 -- Strengthened the contrib.messages tests' isolation to avoid failures under certain project setting environments. Thanks to Boldewyn for the report and to Claude Paroz for the patch.

comment:12 by Julien Phalip, 13 years ago

In [17032]:

(The changeset message doesn't reference this ticket)

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