Menu

#359 Test suite fails on Python 3.8

closed-fixed
nobody
None
5
2020-03-03
2019-03-14
No

Python 3.8 now preserves XML attribute insertion order, rather than sorting them, when writing XML into a file. This change broke the test suite. Example:

FAIL: test_odt_basic (test_writers.test_odt.DocutilsOdtTestCase)
...
AssertionError: content.xml not equal: expected len: 1961  actual len: 1961

Change introduced in Python 3.8 by:
* https://github.com/python/cpython/commit/5598cc90c745dab827e55fadded42dbe85e31d33
* https://bugs.python.org/issue34160

Discussion

  • STINNER Victor

    STINNER Victor - 2019-03-14

    The issue has been detected on Fedora Rawhide while testing Python 3.8: https://bugzilla.redhat.com/show_bug.cgi?id=1687377

     
  • engelbert gruber

    might be due to some changes in sorting of keys/fields

     
  • STINNER Victor

    STINNER Victor - 2019-08-14

    The Python ElementTree documentation now suggests this recipe to sort XML attributes:

    def reorder_attributes(root):
    for el in root.iter():
    attrib = el.attrib
    if len(attrib) > 1:
    # adjust attribute order, e.g. by sorting
    attribs = sorted(attrib.items())
    attrib.clear()
    attrib.update(attribs)

    This function can be used in any Python versions.

    https://docs.python.org/dev/library/xml.etree.elementtree.html

     
  • engelbert gruber

    • status: open --> closed-fixed
     
  • engelbert gruber

    many thanks

     

Log in to post a comment.