[issue16288] TextTestResult uses TestCase.__str__() which isn't customisable (vs id() or shortDescription())
Chris Jerdonek
report at bugs.python.org
Tue Sep 13 07:52:14 EDT 2016
Chris Jerdonek added the comment:
An idea occurred to me on this recently. Instead of changing TextTestResult to call test.id() everywhere instead of str(test), what about making TextTestResult DRY by having it call a new method called something like self.getName(test)?
With this approach, customizing the test name would simply be a matter of subclassing TextTestResult and overriding TextTestResult.getName() (which unittest makes easy). This is much easier than trying to modify the test cases themselves (which unittest doesn't make easy). It's also more natural as the responsibility for formatting should lie with the test result classes rather than with the test case classes themselves (e.g. as discussed in #22431).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16288>
_______________________________________
More information about the Python-bugs-list
mailing list