Author zach.ware
Recipients brett.cannon, ncoghlan, zach.ware
Date 2014-08-07.20:49:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1407444567.64.0.0425446064781.issue22166@psf.upfronthosting.co.za>
In-reply-to
Content
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):
    global _suite
    if _suite is None:
        _suite = suite
    return _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"?
History
Date User Action Args
2014-08-07 20:49:27zach.waresetrecipients: + zach.ware, brett.cannon, ncoghlan
2014-08-07 20:49:27zach.waresetmessageid: <1407444567.64.0.0425446064781.issue22166@psf.upfronthosting.co.za>
2014-08-07 20:49:27zach.warelinkissue22166 messages
2014-08-07 20:49:27zach.warecreate