Opened 10 years ago

Closed 10 years ago

#24331 closed Bug (wontfix)

SuccessMessageMixinTests fail if MESSAGE_STORAGE is not CookieStorage

Reported by: Matt Leach Owned by: nobody
Component: contrib.messages Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The TestCase messages_tests.text_mixins.SuccessMessageMixinTestschecks that a cookie has been created. This means it will fail if the settings object MESSAGE_STORAGE is set to django.contrib.messages.storage.session.SessionStorage or anything that isn't CookieStorage.

Probably best to fix using an override_settings(MESSAGE_STORAGE='django.contrib.messages.storage.cookie.CookieStorage') decorator.

Change History (4)

comment:1 by Tim Graham, 10 years ago

I don't think there's a need to specify default settings in override_settings() everywhere we rely on them. Did you have some use case in mind?

comment:2 by Matt Leach, 10 years ago

Fair enough. I didn't have a use case except that it means the tests will fail if you change the MESSAGE_STORAGE variable.

comment:3 by Matt Leach, 10 years ago

Have just noticed that in tests/messages_tests/urls.py ContactFormViewWithMsg should use reverse_lazy (as below) rather than passing in the view object to success url (success_url = show). Is that worth fixing?

class ContactFormViewWithMsg(SuccessMessageMixin, FormView):
    form_class = ContactForm
    success_url = reverse_lazy('show_message')
    success_message = "%(name)s was created successfully"

comment:4 by Tim Graham, 10 years ago

Resolution: wontfix
Status: newclosed

Sure, I guess it might be nice if the test actually verified that value since even success_url = 'foo' doesn't result in a test failure. Feel free to submit a PR.

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