#7441 closed (fixed)
Doctest OutputChecker for xml and json
Reported by: | Leo Soto M. | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Keywords: | jython | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, there are many doctests which checks for XHTML and JSON output. These checks don't pass on Jython, because the differences in dictionary attribute ordering tend to produce output where the XML or JSON attribute ordering is also different of what is expected.
The attached patch adds XML and JSON checking to django.test.testcases.OutputChecker, allowing this tests to pass on Jython (and, presumably, on other VMs).
Attachments (2)
Change History (11)
by , 16 years ago
Attachment: | doctest_xml_and_json_checkers.patch added |
---|
comment:1 by , 16 years ago
Component: | Uncategorized → Unit test system |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
follow-up: 4 comment:3 by , 16 years ago
Except for an "oh dear... more processing in the test suite to slow things down" sinking feeling, I really like this approach. I'm sure I'll learn to overcome that former problem in the many minutes I spend contemplating my navel whilst waiting for the tests to run,
comment:4 by , 16 years ago
Replying to mtredinnick:
Except for an "oh dear... more processing in the test suite to slow things down"
Yep, it will slow things down a bit, but only if the other output checkers (which are ran first) don't yield a successful comparison. Right now, this means zero slowdown on CPython, and some slowdown on Jython, in places where we previously had failures.
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [7981]) Fixed #7441 - Improved the doctest OutputChecker to be more lenient with JSON an XML outputs. This is required so that output ordering that doesn't matter at a semantic level (such as the order of keys in a JSON dictionary, or attributes in an XML element) isn't caught as a test failure. Thanks to Leo Soto for the patch.
by , 16 years ago
Attachment: | 7441_wrapper_for_xml_outputchecker.diff added |
---|
comment:6 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Seems that the looks_like_markup
method was a premature optimization which are doing more harm that good. On source:django/trunk/tests/regressiontests/admin_widgets/models.py there are doctest output like:
e
Currently: <a target="_blank" href="%(MEDIA_URL)stest">test</a> <br />Change: <input type="file" name="test" />
So I think we have to drop that (the repr_re
hack also not very good, raising false negatives with every attribute value containing "at" or "object".
Also the "wrapper" strategy to check xml fragments was dropped from the patch when it was committed to trunk, but it is needed for cases like the shown above.
I'm attaching a patch fixing these two issues.
comment:8 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Sorry - that last change was me.