Opened 13 years ago

Closed 13 years ago

#16921 closed New feature (fixed)

Add assertHTMLEqual and related assert methods to TestCase

Reported by: Carl Meyer Owned by: Gregor Müllegger
Component: Testing framework Version: dev
Severity: Normal Keywords: form-rendering
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This need came out of the form-rendering GSoC branch, due to a bunch of existing form rendering tests that test against HTML strings. Switching to template-based rendering would often cause spurious test failures due to irrelevant differences in HTML tag attribute ordering or whitespace. So in the branch we've added assertHTMLEqual and assertHTMLNotEqual methods, as well as a boolean "html" argument to assertContains.

These additions can be committed separately from the rest of the branch, but need to be split out first.

Most up-to-date code for the branch is at https://github.com/carljm/django/compare/master...soc2011%2Fform-rendering

Attachments (1)

16921-assertHTMLEqual.1.diff (32.8 KB ) - added by Gregor Müllegger 13 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Carl Meyer, 13 years ago

The Python standard library HTMLParser bug described here and here is an issue that needs to be resolved before this patch is ready for trunk. One possible workaround is demonstrated here.

comment:2 by Gregor Müllegger, 13 years ago

Owner: changed from nobody to Gregor Müllegger
Status: newassigned

The mentioned bug is fixed. Attached is a patch with the feature including tests and documentation.
It would be nice if someone could especially review the english texts in docs and release notes.

I consider the code itself as pretty stable since it's already used in my gsoc form-rendering branch.

Here is a link to my branch of this bug: https://github.com/gregmuellegger/django/tree/t16921-assertHTMLEqual

And the compare view: https://github.com/gregmuellegger/django/compare/master...t16921-assertHTMLEqual

comment:3 by Gregor Müllegger, 13 years ago

Next step now is to eat our own dog food and using this feature were suitable in django's test-suite.

Most of the work is already done in my soc2011/form-rendering branch, but needs a bit of work to extract it: https://github.com/gregmuellegger/django/tree/soc2011/form-rendering

comment:4 by Claude Paroz, 13 years ago

Has patch: unset
Patch needs improvement: unset

Thanks, but it would still be welcome to attach a diff version of your work to this ticket.

by Gregor Müllegger, 13 years ago

comment:5 by Gregor Müllegger, 13 years ago

oops, I prepared it but forgot to attach it. Here it is.

comment:6 by Gregor Müllegger, 13 years ago

I copied over my work from the gsoc branch to use the new assertions where suiteable in django's test suite. Unfortunatelly, the patch is with >350kb too big for trac. It rejects the upload.

You can download the current status via github:

wget https://github.com/gregmuellegger/django/compare/master...t16921-assertHTMLEqual.diff
Last edited 13 years ago by Gregor Müllegger (previous) (diff)

comment:8 by Claude Paroz, 13 years ago

Has patch: set

comment:9 by Carl Meyer, 13 years ago

Resolution: fixed
Status: assignedclosed

In [17414]:

Fixed #16921 -- Added assertHTMLEqual and assertHTMLNotEqual assertions, and converted Django tests to use them where appropriate. Thanks Greg Müllegger.

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