Opened 6 years ago

Closed 6 years ago

#9470 closed (duplicate)

PasswordResetTest.test_email_not_found built in test chokes on apostrophe

Reported by: sam@… Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: sam@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This is my first bug report, so I apologize if it's cryptic :)

I get the following error when running django's built-in tests:

======================================================================
FAIL: Error is raised if the provided email address isn't currently registered
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Applications/Django/django-trunk/django/contrib/auth/tests/views.py", line 21, in test_email_not_found
    self.assertContains(response, "That e-mail address doesn't have an associated user account")
  File "/Applications/Django/django-trunk/django/test/testcases.py", line 274, in assertContains
    "Couldn't find '%s' in response" % text)
AssertionError: Couldn't find 'That e-mail address doesn't have an associated user account' in response

----------------------------------------------------------------------

It seems the test is choking on the apostrophe. Changing line 20 in django/contrib/auth/tests/views.py to the following solves the problem:

self.assertContains(response, "That e-mail address doesn")

or the following also works:

try:
	self.assertContains(response, "That e-mail address doesn't have an associated user account")
except:
	self.assertContains(response, "That e-mail address doesn't have an associated user account.")

Change History (1)

comment:1 Changed 6 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

I don't really understand why you are seeing this error. This test passes for me. There is a ticket (#6160) to add escaping to validation error messages, and part of the patch for that ticket changes these tests to expect the apostrophes to be escaped (I'm also puzzled by why fixing this single apostrophe fixes your issue -- there are two others in that test file -- why don't you see errors on them?). So I'm going to call this a dup of that ticket, since I believe the fix for that will fix whatever is causing this in your case as well.

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