Gregory P. Smith <g...@krypto.org> added the comment:
I spent a while looking at this and what it'd take to wind up with a TestCase.maxReprLength style implementation to limit the length of unittest assertion failure reprs. I don't see a nice path forward via safe_repr as is (as the PR started with). adding max_length as the PR does is easy enough... but plumbing everything through is rather gross. mostly mechanical changes I started in a client before abandoning the work: 1 change all TestCase method safe_repr calls to self._safe_repr method calls so that the method could pass self.maxReprLength in via max_length=. 2 realize that this is mostly pointless without also updating unittest.util._common_shorten_repr which calls safe_repr in a similar manner. do that... 3 and notice how we have many calls of safe_repr on safe_repr'ed things and the nesting between _common_shorten_repr and safe_repr which makes for messy uninformative potentially misleading error messages when maxReprLength was actually set to a value. Overall I think we should backup and reconsider what we want our unittest assertions to do and how if we're going to add error message length constraining as a feature. shoehorning it in via the existing repr implementations doesn't feel right. So I closed that PR. unittest.safe_repr (aka unittest.util.safe_repr) remains an undocumented API. future to be determined. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27432> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com