Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#10976 closed (fixed)

missing template files for correctly executing test cases on django.contrib.auth

Reported by: aarond10 Owned by: SmileyChris
Component: Testing framework 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

This has taken me a while to wrap my head around. I hope I have it right.

When the test cases for django.contrib.auth run, they reassign settings.TEMPLATE_DIRS to use a local set of templates. This works fine for login purposes but the password reset pages don't exist in the current SVN repository so application paths are searched and if password_reset_email.html can be found elsewhere, its loaded and rendered. Unfortunately, since the test cases also use their own URLs, any references to named {% url %} tags in password_reset_email.html lead to NoReverseMatch exceptions.

Could someone please put some basic templates in the contrib/auth/tests/templates/ folder to avoid these errors?

Attachments (1)

10976.diff (2.9 KB) - added by SmileyChris 6 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 6 years ago by aarond10

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Sorry, I havent had time to put these in patch format but the changes are trivial.

django/contrib/auth/tests/views.py:

Remove the setUp() and tearDown() functions in the PasswordResetTest class.

django/contrib/auth/tests/templates/registration/password_reset_form.html

{{ form }}

django/contrib/auth/tests/templates/registration/password_reset_email.html

{{ protocol }}:{{ domain }}/reset/{{ uid }}-{{ token }}/

django/contrib/auth/tests/templates/registration/password_reset_confirm.html

{% if validlink %}

Please enter your new password:
{{ form }}

{% else %}

The password reset link was invalid

{% endif %}

django/contrib/auth/tests/templates/registration/password_reset_done.html
django/contrib/auth/tests/templates/registration/password_reset_complete.html

Empty file will do fine.

comment:2 Changed 6 years ago by russellm

  • milestone 1.1 deleted

comment:3 Changed 6 years ago by arthurk

  • Owner changed from nobody to arthurk

comment:4 Changed 6 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Accepted

Changed 6 years ago by SmileyChris

comment:5 Changed 6 years ago by SmileyChris

  • Has patch set
  • milestone set to 1.2
  • Triage Stage changed from Accepted to Ready for checkin

Here's a patch which adds the missing template files (and I verify that this fixes the auth test errors related to overridden template files for me).

#11009 covered fixing just the incomplete duplicate setUp and tearDown methods, so I marked that as a duplicate of this one

comment:6 Changed 6 years ago by SmileyChris

  • Owner changed from arthurk to SmileyChris
  • Status changed from new to assigned

comment:7 Changed 5 years ago by russellm

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

(In [12420]) Fixed #10976 -- Isolated contrib.auth tests so they will always pass, regardless of any local templates. Thanks to aarond10 for the report, and SmileyChris for turning that into a patch.

comment:8 Changed 5 years ago by russellm

(In [12422]) [1.1.X] Fixed #10976 -- Isolated contrib.auth tests so they will always pass, regardless of any local templates. Thanks to aarond10 for the report, and SmileyChris for turning that into a patch.

Backport of r12420 from trunk.

comment:9 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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