[New-bugs-announce] [issue22166] test_codecs "leaking" references
report at bugs.python.org
Thu Aug 7 22:49:27 CEST 2014
New submission from Zachary Ware:
After 9bca86812857 (#22104), test_codecs now reports "leaked" references from ExceptionChainingTest. Previously the tests were only ever loaded one time, so each run of the tests was actually using the same set of TestCase instances; now the tests are freshly loaded before every test run and thus each run uses a new set of TestCase instances. My suspicion is that this is coming into play in ExceptionChainingTest.setUp, where the test's codec_name attribute is derived from the repr and id of the TestCase instance. However, I'm not familiar enough with the codecs code to know where it's going wrong from there.
One possible "fix" is to abuse load_tests to ensure the tests are only loaded once:
_suite = None
def load_tests(loader, suite, pattern):
if _suite is None:
_suite = suite
...which restores the old behavior, but strikes me as a fairly horrible hack. Somewhat less bad would be to just skip those tests when they've already been run before. I can't help but feel that there has to be a better solution that I can't see, though.
Nick, as the original author of the test class in question, do you have any insight into a better way to fix the "leaks"?
nosy: brett.cannon, ncoghlan, zach.ware
title: test_codecs "leaking" references
versions: Python 3.4, Python 3.5
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce