� S�Ljc@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"    *