Message344343
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. |
|
Date |
User |
Action |
Args |
2019-06-03 00:12:27 | gregory.p.smith | set | recipients:
+ gregory.p.smith, r.david.murray, Camilla Ke, Mariatta, cheryl.sabella, jiliuk |
2019-06-03 00:12:27 | gregory.p.smith | set | messageid: <1559520747.84.0.820069513694.issue27432@roundup.psfhosted.org> |
2019-06-03 00:12:27 | gregory.p.smith | link | issue27432 messages |
2019-06-03 00:12:27 | gregory.p.smith | create | |
|