[New-bugs-announce] [issue16288] TextTestResult uses TestCase.__str__() which isn't customisable (vs id() or shortDescription())

Robert Collins report at bugs.python.org
Fri Oct 19 20:34:49 CEST 2012


New submission from Robert Collins:

TextTestRunner calls str(TestCase) directly, which makes it hard for testscenarios to rename the test cases as it parameterises them (because __str__ is a descriptor). While testscenarios could use a decorator instead, thats undesirable as the test case object would still need to be customised so that calls to self.id() and self.shortDescription() inside it still return consistent information.

So the relevant code is this:
 def getDescription(self, test):
41 if self.descriptions:
42 return test.shortDescription() or str(test)
43 else:
44 return str(test)

What I'd like is to have this be something like:
41 if self.descriptions:
42     return test.shortDescription() or test.id()
43 else:
44     return test.id()

Which would let testscenarios adjust both shortDescriptions and id, and Just Work.

----------
messages: 173352
nosy: michael.foord, rbcollins
priority: normal
severity: normal
status: open
title: TextTestResult uses TestCase.__str__() which isn't customisable (vs id() or shortDescription())
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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


More information about the New-bugs-announce mailing list