K idZddlZddlZddlZddlZGddej ZGddeZe edrdZ ejZ yd Z d Z y) a[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. Nc.eZdZdZdZdZdZdZdZy)LocalTestResultzHA TestResult which forwards events to a parent object, except for Skips.cPtjj|||_yN)unittest TestResult__init__ parent_result)selfr s o/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/google/protobuf/internal/testing_refleaks.pyr zLocalTestResult.__init__s   &&Dc<|jj||yr)r addErrorr testerrors r rzLocalTestResult.addErrorse,r c<|jj||yr)r addFailurers r rzLocalTestResult.addFailure"s!!$.r cyr)r rreasons r addSkipzLocalTestResult.addSkip%r cyrr)r rdurations r addDurationzLocalTestResult.addDuration(rr N) __name__ __module__ __qualname____doc__r rrrrrr r rrsP'-/  r rc.eZdZdZdZdfd ZdZxZS)ReferenceLeakCheckerMixinz:A mixin class for TestCase, which checks reference counts.ct||j}t|dd}t|dd}|s|rytjj |_t t|#|t t|#|t|}d}g}|j}t||jkrs|j}t t|#||j} | |kr |dkr|dz }\d}|j| |z t||jkrst|| |j|dg|jzy#t $r'|j#|t%j&YywxYw)N__unittest_expecting_failure__F)resultr)getattr_testMethodNamecopyregdispatch_tablecopy_saved_pickle_registrysuperr"runr _getRefcountslenNB_RUNSappendprint assertEqual Exceptionrsysexc_info) r r& testMethodexpecting_failure_methodexpecting_failure_class local_result num_flakesrefcount_deltas oldrefcount newrefcount __class__s r r0zReferenceLeakCheckerMixin.run1s|t334J&z3SUZ[%d,LeT": #*"8"8"="="?D #T.f.= #T.f.="6*LJO$$&K o  -&&(k %t0 0E&&(k { "zA~ a j[;67 o  - /4 , dll(:; , oodCLLN+,s9 E-F  F cttdrtjntjtj j tj j|jtjtjtjtjS)N_clear_internal_caches) hasattrr8rD_clear_type_cacher+r,clearupdater.gccollectgettotalrefcount)r s r r1z'ReferenceLeakCheckerMixin._getRefcounts^s}s,-   "    " !!$"="=>JJLJJLJJL    !!r r)rrrr r3r0r1 __classcell__)rBs@r r"r",sB '+,Z "r r"rKctf|jz}t||j|t |j }|Sr)r" __bases__typerdict__dict__) test_class new_bases new_classs r TestCaserUosE*,z/C/CCI Z YZ-@-@(ACI r c|Srr)rRs r rUrUys r c~d}|S)Nc|Srr)funcs r Samez&SkipReferenceLeakChecker..Same~s kr r)rrZs r SkipReferenceLeakCheckerr[|s Kr ) r r+rIr8rrrobjectr"rErUskipr[rr r r^s_  h)) (>">"B 3"# &]] r