Opened 7 years ago

Closed 7 years ago

#13615 closed (fixed)

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

Reported by: Daniel Duan 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:

Description

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 Daniel Duan 7 years ago.
Replace "page" with "content" in the assertContains failure msg.
testcase_msg_r2.diff (3.9 KB) - added by Daniel Duan 7 years ago.
With regression test modified.

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by Daniel Duan

Attachment: testcase_msg.diff added

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

comment:1 Changed 7 years ago by Russell Keith-Magee

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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 7 years ago by Daniel Duan

Patch needs improvement: unset

Here, now its fixed

Changed 7 years ago by Daniel Duan

Attachment: testcase_msg_r2.diff added

With regression test modified.

comment:3 Changed 7 years ago by Russell Keith-Magee

Triage Stage: AcceptedReady for checkin

comment:4 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(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