Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#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)

doctest_xml_and_json_checkers.patch (5.7 KB ) - added by Leo Soto M. 17 years ago.
7441_wrapper_for_xml_outputchecker.diff (2.2 KB ) - added by Leo Soto M. 16 years ago.

Download all attachments as: .zip

Change History (11)

by Leo Soto M., 17 years ago

comment:1 by anonymous, 17 years ago

Component: UncategorizedUnit test system
Triage Stage: UnreviewedAccepted

comment:2 by Russell Keith-Magee, 17 years ago

Sorry - that last change was me.

comment:3 by Malcolm Tredinnick, 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,

in reply to:  3 comment:4 by Leo Soto M., 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 Russell Keith-Magee, 16 years ago

Resolution: fixed
Status: newclosed

(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 Leo Soto M., 16 years ago

comment:6 by Leo Soto M., 16 years ago

Resolution: fixed
Status: closedreopened

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:7 by Leo Soto M., 16 years ago

Oops, sorry for the amount of typos, forgot to preview the message.

comment:8 by Russell Keith-Magee, 16 years ago

Resolution: fixed
Status: reopenedclosed

(In [8003]) Fixed #7441 -- Removed some of the shortcuts in the doctest output comparators, and added a wrapper to allow comparison of xml fragments. Thanks to Leo Soto for the report and fix.

comment:9 by Russell Keith-Magee, 16 years ago

(In [8005]) Made the test case for doctest comparison of XML fragments a little more rigorous. Refs #7441.

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