Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#15016 closed (fixed)

Minor contrib.messages test isolation problem

Reported by: gabrielhurley Owned by: gabrielhurley
Component: Contrib apps Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When running manage.py test on a project with django.contrib.messages in INSTALLED_APPS, if you have a customized 500.html template which uses the {% url %} tag to try and resolve any namespaced urls you'll get errors from the test_middleware_disabled_anon_user test for each of the message backend test classes. Since the base test class overrides the project urls, any custom url namespaces are unresolvable when the test intentionally triggers a server error, causing the test to error out.

Basically the test just needs better isolation from the rest of the project.

Attachments (1)

15016_messages_test_isolation.diff (1.0 KB) - added by gabrielhurley 4 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

contrib.auth.tests.views.AuthViewsTestCase contains an example of how to do this -- override TEMPLATE_DIRS as part of the test setUp/tearDown.

Changed 4 years ago by gabrielhurley

comment:2 Changed 4 years ago by gabrielhurley

  • Has patch set
  • Status changed from new to assigned

Added a very simple patch that fixes the four test failures seen under the described conditions.

comment:3 Changed 4 years ago by PaulM

  • Triage Stage changed from Accepted to Ready for checkin

Looks good (and works) for me. Marking as RFC.

comment:4 Changed 4 years ago by russellm

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

In [15407]:

Fixed #15016 -- Ensured that the messages tests are isolated from local template directories. Thanks to Gabriel Hurley for the report and patch.

comment:5 Changed 4 years ago by russellm

In [15408]:

[1.2.X] Fixed #15016 -- Ensured that the messages tests are isolated from local template directories. Thanks to Gabriel Hurley for the report and patch.

Backport of r15407 from trunk.

comment:6 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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