Opened 6 years ago

Closed 5 years ago

#13615 closed (fixed)

test.TestCase.assert(Not)Contains assumes response content is a page.

Reported by: DaNmarner Owned by: nobody
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:


Currently, if a test fails on django.TestCase.assertContains/assertNotContains(), Django says "Couldn't retrieve page: Response code was %d", which is an odd message if someone expects the response content is not a web page.

It took me about 2 minutes to comprehend this message the first time when I was working on a webapp that speaks JSON.

The message should use the word "content" instead of "page", it does make a difference.

Attachments (2)

testcase_msg.diff (2.1 KB) - added by DaNmarner 6 years ago.
Replace "page" with "content" in the assertContains failure msg.
testcase_msg_r2.diff (3.9 KB) - added by DaNmarner 5 years ago.
With regression test modified.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by DaNmarner

Replace "page" with "content" in the assertContains failure msg.

comment:1 Changed 5 years ago by russellm

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

Patch as written will break the tests in the regression test suite that check the exceptions that are raised by assert(Not)Contains.

comment:2 Changed 5 years ago by DaNmarner

  • Patch needs improvement unset

Here, now its fixed

Changed 5 years ago by DaNmarner

With regression test modified.

comment:3 Changed 5 years ago by russellm

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 5 years ago by russellm

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

(In [13512]) Fixed #13615 -- Clarified test assertion text to avoid confusion when response content isn't a web page. Thanks to DaNmarner for the report and patch.

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