[Python-modules-team] Bug#732679: test_nodes.ElementTests.test_empty fails for py3: "=?UTF-8?Q?=E2=80=A2?=" != "\\u2022"

Martin Pitt mpitt at debian.org
Fri Dec 20 09:14:15 UTC 2013


Package: python-docutils
Version: 0.11-2

Hello,

Since recently [1], python-docutils' python3 test fail [2], most
likely since the update of python3 from 3.3.2 to 3.3.3:

======================================================================
FAIL: test_empty (__main__.ElementTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test3/test_nodes.py", line 95, in test_empty
AssertionError: '<Element mark="•"/>' != '<Element mark="\\u2022"/>'
- <Element mark="•"/>
?                ^
+ <Element mark="\u2022"/>
?                ^^^^^^

This is with LANG=en_US.UTF-8 or C.UTF-8. With the C locale (ASCII
only), I get

  AssertionError: '<Element mark="\u2022"/>' != '<Element mark="\\u2022"/>'

instead.

The quickest way to reproduce this is

$ python3 setup.py build --build-lib=build/py3/
$ python3 test3/test_nodes.py ElementTests.test_empty

(just tested in a clean and up to date sid schroot.)

The most likely cause is the 2to3 conversion of the test. The original code
alreaydy differs between 2 and 3:

        if sys.version_info < (3,):
            self.assertEqual(str(element), '<Element mark="\\u2022"/>')
        else:
            self.assertEqual(str(element), '<Element mark="\u2022"/>')


But in test3/, 2to3 mangles this to

        if sys.version_info < (3,):
            self.assertEqual(str(element), '<Element mark="\\u2022"/>')
        else:
            self.assertEqual(str(element), '<Element mark="\\u2022"/>')

I. e. exactly the same for both python versions. If I un-break the
additional \, then \u2022 is in fact the right representation of •,
and the test works again.

I'm not sure whether this is an overzealous 2to3 conversion, or
whether 2to3 is actually right.

FTR, tests with python2 work with both C and C.UTF-8.

Thanks for considering,

Martin

[1] https://jenkins.qa.ubuntu.com/job/trusty-adt-python-docutils/?
[2] https://jenkins.qa.ubuntu.com/job/trusty-adt-python-docutils/4/ARCH=i386,label=adt/artifact/results/dsc0t-python3-docutils-stdout
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)



More information about the Python-modules-team mailing list