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)
Change History (10)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
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 , 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 , 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 , 13 years ago
Attachment: | 16921-assertHTMLEqual.1.diff added |
---|
comment:6 by , 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
comment:7 by , 13 years ago
A new update, the link is still valid:
https://github.com/gregmuellegger/django/compare/master...t16921-assertHTMLEqual.diff
comment:8 by , 13 years ago
Has patch: | set |
---|
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.