ó Du—ac@sçdZddlZddlZyddlZWnek rMddlZnXyddlZWnek r}ddlZnXdejfd„ƒYZ dej fd„ƒYZ e edƒrÑe Z ejZnej Z d„ZdS( s[A subclass of unittest.TestCase which checks for reference leaks. To use: - Use testing_refleak.BaseTestCase instead of unittest.TestCase - Configure and compile Python with --with-pydebug If sys.gettotalrefcount() is not available (because Python was built without the Py_DEBUG option), then this module is a no-op and tests will run normally. iÿÿÿÿNtLocalTestResultcBs2eZdZd„Zd„Zd„Zd„ZRS(sHA TestResult which forwards events to a parent object, except for Skips.cCstjj|ƒ||_dS(N(tunittestt TestResultt__init__t parent_result(tselfR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyR:scCs|jj||ƒdS(N(RtaddError(Rttestterror((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyR>scCs|jj||ƒdS(N(Rt addFailure(RRR((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyR AscCsdS(N((RRtreason((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pytaddSkipDs(t__name__t __module__t__doc__RRR R (((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyR7s    tReferenceLeakCheckerTestCasecBs)eZdZdZdd„Zd„ZRS(sHA TestCase which runs tests multiple times, collecting reference counts.icCstjjƒ|_tt|ƒjd|ƒtt|ƒjd|ƒd}t|ƒ}g}xYt|j ƒD]H}|j ƒ}tt|ƒjd|ƒ|j ƒ}|j ||ƒqlW||fGHy|j |dg|j ƒWn't k r |j|tjƒƒnXdS(Ntresulti(tcopyregtdispatch_tabletcopyt_saved_pickle_registrytsuperRtrunRtrangetNB_RUNSt _getRefcountstappendt assertEqualt ExceptionRtsystexc_info(RRt oldrefcountt local_resulttrefcount_deltast_t newrefcount((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyRMs      cCsHtjjƒtjj|jƒtjƒtjƒtjƒtjƒS(N( RRtcleartupdateRtgctcollectRtgettotalrefcount(R((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyRgs     N(R R RRtNoneRR(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyRHs R(cCs~d„}|S(NcSs|S(N((tfunc((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pytSame|s((R R+((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pytSkipReferenceLeakCheckerzs (RR&Rtcopy_regRt ImportErrort unittest2RRRtTestCaseRthasattrt BaseTestCasetskipR,(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/testing_refleaks.pyt's"    *