lxml.doctestcompare diffs reverse the usual meaning of -expected +actual

Bug #1238503 reported by Marius Gedminas on 2013-10-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Low
Marius Gedminas

Bug Description

Test case:

    $ python2.7
    >>> import doctest
    >>> __test__ = dict(ex=r'''
    ... >>> print 'One\nTwo\nThree' # doctest: +REPORT_NDIFF
    ... One
    ... >>> import lxml.usedoctest
    ... >>> print '<p><span>One</span><b>Two</b><em>Three</em></p>'
    ... <p><span>One</span></p>
    ... ''')
    >>> doctest.testmod()

Now look at the diff of the first example:

    **********************************************************************
    File "__main__", line ?, in __main__.__test__.ex
    Failed example:
        print 'One\nTwo\nThree' # doctest: +REPORT_NDIFF
    Differences (ndiff with -expected +actual):
          One
        + Two
        + Three

It uses '+' to indicate items in actual output that were not present in the expected output.

Compare with what lxml produces:

    **********************************************************************
    File "__main__", line ?, in __main__.__test__.ex
    Failed example:
        print '<p><span>One</span><b>Two</b><em>Three</em></p>'
    Expected:
      <p>
        <span>One</span>
      </p>

    Got:
      <p>
        <span>One</span>
        <b>Two</b>
        <em>Three</em>
      </p>

    Diff:
      <p>
        <span>One</span>
        -<b>Two</b>
        -<em>Three</em>
      </p>
    **********************************************************************

It uses '-' for the same purpose.

Additional info:

Python : sys.version_info(major=2, minor=7, micro=4, releaselevel='final', serial=0)
lxml.etree : (3, 1, 0, 0)
libxml used : (2, 9, 0)
libxml compiled : (2, 9, 0)
libxslt used : (1, 1, 27)
libxslt compiled : (1, 1, 27)

scoder (scoder) wrote :

Yes, looks wrong. I'd take pull requests that fix this.

Changed in lxml:
importance: Undecided → Low
status: New → Confirmed
description: updated
scoder (scoder) wrote :
Changed in lxml:
assignee: nobody → Marius Gedminas (mgedmin)
milestone: none → 3.5
status: Confirmed → Fix Committed
scoder (scoder) wrote :

Fixed in lxml 3.5.0.

Changed in lxml:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers