Code

Opened 3 years ago

Closed 2 years ago

#16921 closed New feature (fixed)

Add assertHTMLEqual and related assert methods to TestCase

Reported by: carljm Owned by: gregmuellegger
Component: Testing framework Version: master
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 gregmuellegger 2 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 3 years ago by carljm

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 Changed 2 years ago by gregmuellegger

  • Owner changed from nobody to gregmuellegger
  • Status changed from new to 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 Changed 2 years ago by gregmuellegger

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 Changed 2 years ago by claudep

  • 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.

Changed 2 years ago by gregmuellegger

comment:5 Changed 2 years ago by gregmuellegger

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

comment:6 Changed 2 years ago by gregmuellegger

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 2 years ago by gregmuellegger (previous) (diff)

comment:8 Changed 2 years ago by claudep

  • Has patch set

comment:9 Changed 2 years ago by carljm

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

In [17414]:

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.