[issue21820] unittest: unhelpful truncating of long strings.

Chris Withers report at bugs.python.org
Sat Jun 21 12:34:46 CEST 2014


New submission from Chris Withers:

This code, prior to 3.4:

from testfixtures import Comparison as C

class AClass:
    def __init__(self,x,y=None):
        self.x = x
        if y:
            self.y = y
    def __repr__(self):
        return '<'+self.__class__.__name__+'>'

...

self.assertEqual(
    C('testfixtures.tests.test_comparison.AClass',
      y=5, z='missing'),
      AClass(1, 2))

Would give the following output in the failure message:

"""
<C(failed):testfixtures.tests.test_comparison.AClass>
  x:1 not in Comparison
  y:5 != 2
  z:'missing' not in other
</C> != <AClass>"
"""

Now, in 3.4, you get the (rather unhelpful):

"""
<C(failed):testfixtures.tests.test_com[79 chars] </C> != <AClass>
"""

It's particularly disappointing that there's no API (class attribute, etc) to control whether or not this new behaviour is enabled.

I believe the change that introduced this behaviour was in [issue18996]

----------
components: Tests
keywords: 3.4regression
messages: 221167
nosy: cjw296
priority: normal
severity: normal
status: open
title: unittest: unhelpful truncating of long strings.
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21820>
_______________________________________


More information about the Python-bugs-list mailing list