a 5dg^q@sddlZddlZddlZddlZddlZddlmZddlZddlm Z ddl Z ddl m Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlmZddlZddlmZddlZe jddgd Ze jddgd Ze jd d gd Zejd dZddZ ddZ!Gddde"Z#Gddde"Z$Gddde%Z&GdddZ'e(edGddde'ej)Z*Gddde'ej)Z+erGd d!d!ej,Z-Gd"d#d#ej,Z.e(edGd$d%d%e*Z/Gd&d'd'e+Z0Gd(d)d)ej)Z1Gd*d+d+ej)Z2Gd,d-d-e2Z3Gd.d/d/Z4e(edGd0d1d1e4ej)Z5Gd2d3d3e4ej)Z6Gd4d5d5Z7e(edGd6d7d7e7ej)Z8Gd8d9d9e7ej)Z9Gd:d;d;ej)Z:ej;Gdd?d?Z=Gd@dAdAZ>e?dBdCZ@e?dDdEZAGdFdGdGe>ej)ZBGdHdIdIe>ej)ZCGdJdKdKej)ZDGdLdMdMZEGdNdOdOZFGdPdQdQZGGdRdSdSZHGdTdUdUej)ZIeJdVkreKdS)WN) permutations)choice)support)proxy)assert_python_ok functools _functools)Zblocked)ZfreshdecimalZ_decimalc cs:tj|}|tj|<zdVW|tj|<n |tj|<0dSN)sysmodules)nameZ replacementZoriginal_moduler//usr/local/lib/python3.9/test/test_functools.pyreplaced_modules   rcOs||fSr r)argskwrrrcapture(srcCs|j|j|j|jfSr )funcrkeywords__dict__)partrrr signature-src@s eZdZdS)MyTupleN__name__ __module__ __qualname__rrrrr1src@seZdZddZdS)BadTuplecCst|t|Sr )listselfotherrrr__add__5szBadTuple.__add__N)rrrr#rrrrr4src@s eZdZdS)MyDictNrrrrrr$8sr$c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3S)4 TestPartialc Csx|jtddddd}|t|||dddd d d tddd d f|td d}|t|gd gddS)N ab(r,cr&r'r-r.r+r,r2cSs|dS)Nr(rxrrrCz1TestPartial.test_basic_examples..)r(r)r/r0)partialr assertTruecallable assertEqualdictmaprr!prrrtest_basic_examples>szTestPartial.test_basic_examplescCsJ|jtddddd}||jt||jd||jtddddS)Nr&r'r(r)r*r&r')r9rr<rrrr=r?rrrtest_attributesFszTestPartial.test_attributescCs@|t|jz|dWnty0Yn 0|ddS)Nr'z%First arg not checked for callability) assertRaises TypeErrorr9failr!rrrtest_argument_checkingMs  z"TestPartial.test_argument_checkingcCsdd dd}ddi}|j|dd}||fi|d||ddi|d d ||ddidS) Nr(r)cSs|Sr rr*rrrrXszBTestPartial.test_protection_of_callers_dict_argument..funcr+r-r+r,)r(r))r9r<)r!rdr@rrr(test_protection_of_callers_dict_argumentVs  z4TestPartial.test_protection_of_callers_dict_argumentcCsRddi}|jtfi|}||dddifd|d<||dddifdS)Nr+r-rrIr9rr<)r!rMr@rrrtest_kwargs_copyas zTestPartial.test_kwargs_copycCsl|t}||dif||dddif|tdd}||dif||dddifdS)Nrr&r'rBr-r.r3rOr?rrrtest_arg_combinationsjs  z!TestPartial.test_arg_combinationscCs|t}||ji||dif||dddddif|jtdd}||jddi||dddif||ddddddf||dddddddfdS) Nrr&rJr+r'rLr*r-)r9rr<rr?rrrtest_kw_combinationsts z TestPartial.test_kw_combinationscCsJdD]@}|jtg|R}|d}|d\}}|||ko@|ikqdS)N)rrrr&)rr&r')rr&r'r-r5r6r9rr:)r!rr@expectedgotemptyrrrtest_positionals  zTestPartial.test_positionalcCsJdD]@}|jt|d}|dd}|dd\}}|||ko@|dkqdS)N)r+rNg @rJ)r+r6r5rrU)r!r+r@rVrXrWrrr test_keywords  zTestPartial.test_keywordcCsd|jtddd}|ddd\}}||dko8|dddk|\}}||dko\|d dikdS) Nrr&rJr'rLrTr*rSr+rU)r!r@Zargs1Zkw1Zargs2Zkw2rrrtest_no_side_effectss  z TestPartial.test_no_side_effectscCsfdd}|t||dd|t||dd|t||dd|t|j|ddddS)NcSs ||dSr rr6yrrrfsz-TestPartial.test_error_propagation..fr&r)r])rDZeroDivisionErrorr9r!r^rrrtest_error_propagations z"TestPartial.test_error_propagationcCs>|jtdd}t|}||j|jd}|tt|ddS)N)baser)r9intrr<rrDReferenceErrorgetattrr!r^r@rrr test_weakrefs zTestPartial.test_weakrefcCsPttttd}|tjd}|||d|dj}|||ddS)Nr( 0123456789)rr>strranger9joinr<)r!datarmrrr#test_with_bound_and_unbound_methodss  z/TestPartial.test_with_bound_and_unbound_methodscCsB|j}|td}||dd}|tddd}|t|t|dSNasdfTbar)r9rr<)r!r9innernestedZflatrrrtest_nested_optimizations   z$TestPartial.test_nested_optimizationcCs:|j}dd}||d}||d}d|_||jddS)NcSs|Sr rrrrrrfoosz;TestPartial.test_nested_partial_with_attribute..foofirstsecondZspam)r9Znew_attrr<)r!r9rwr@Zp2rrr"test_nested_partial_with_attributes   z.TestPartial.test_nested_partial_with_attributecs(ttf}ddd|Dttd}d|d|g}|jtjtjfvrZdn|jj|t}|dtd t ||jtg|R}|dtdd t ||jtfi|}| t |fd d |D|jtg|Ri|}| t |fd d |DdS) N, css|]}t|VqdSr )repr).0r+rrr r8z(TestPartial.test_repr..r*za={a!r}, b={b!r}zb={b!r}, a={a!r}functools.partial()cs"g|]}dtd|dqSrr{rrr}Z kwargs_repr)r rr sz)TestPartial.test_repr..c s(g|] }dtdd|dqSrrrZ args_reprr rrrs) objectrm format_mapr9 c_functools py_functoolsrrr<r|assertIn)r!rkwargsZ kwargs_reprsr^rrr test_reprs2  "    zTestPartial.test_reprc CsH|jtjtjfvrd}n|jj}|t}||diifz,|t|d|fW|tdiifn|tdiif0|t}|t|fiifz.|t|d|tfW|tdiifn|tdiif0|t}|tdd|iifz.|t|d|tfW|tdiifn|tdiif0dS)Nrrz%s(...)z %s(%r, ...)r+z %s(%r, a=...))r9rrrr __setstate__r<r|)r!r r^rrrtest_recursive_reprs$ ( ( zTestPartial.test_recursive_reprcCs|d|jtdgdgd}g|_ttjdD]*}tt||}| t|t|q2Wdn1sr0YdS)NrqTrrr&) AllowPickler9rattrrlpickleHIGHEST_PROTOCOLloadsdumpsr<r!r^protof_copyrrr test_pickles  zTestPartial.test_picklecCsl|jtdgdgd}g|_t|}|t|t|||j|j||j|j||j|jdSrp)r9rrcopyr<assertIsrrr!r^rrrr test_copys zTestPartial.test_copycCs|jtdgdgd}g|_t|}|t|t|||j|j||j|j||jd|jd||j|j||jd|jddS)NrqTrrrrs) r9rrrdeepcopyr<Z assertIsNotrrrrrr test_deepcopy s zTestPartial.test_deepcopyc Cs|t}|tdtddtgdf|t|tdtddtgdf||ddddddd f|tdtdddf|t|tdtddif||ddddddd f|tdddf||ddddd dif||ddif||dif|td idf|t|td iif||dddd d dif||dd if||d ifdS) Nr&r(rJrr'r)rLrBr*r,r)r')r9rrrr=r<r`rrr test_setstates$  zTestPartial.test_setstatec Cs|t}|t|jtdif|t|jtdiidf|t|jtdidg|t|jddidf|t|jtdidf|t|jtgidf|t|jtdgdfdS)Nr)r9rrDrErrr`rrrtest_setstate_errors.s z TestPartial.test_setstate_errorscCs(|t}|ttdtdddft|}||tdtddif|t |dt |t |dt|}||dddif|t |dt |t |dt|tt didft|}||tdiif|t |dt |d}||dif|t |dt dS) Nrr(rJr&r'r+rrB) r9rrrrr$r<r=rtypetupler)r!r^srrrrtest_setstate_subclasses8s" z$TestPartial.test_setstate_subclassescCs"||t}||diifz`ttjdD]:}|tt ||Wdq81sh0Yq8W|tdiifn|tdiif0|t}|t|fiifzzttjdD]T}t t ||}z(| |j d|W|tdiifq|tdiif0qW|tdiifn|tdiif0|t}|tdd|iifz|ttjdD]V}t t ||}z(| |j d|W|tdiifn|tdiif0q|W|tdiifn|tdiif0Wdn1s0YdS)Nrr&rr+)rr9rrrlrrrDRecursionErrorrrrrrrrrrtest_recursive_pickleLs4   .( ,( .z!TestPartial.test_recursive_picklecCs.Gddd}|t}|t|j|dS)Nc@seZdZddZddZdS)z7TestPartial.test_setstate_refcount..BadSequencecSsdS)Nr.rrGrrr__len__rsz?TestPartial.test_setstate_refcount..BadSequence.__len__cSs4|dkr tS|dkr ttdS|dvr,iStdS)Nrr&i@B)r'r-)maxrrl IndexError)r!keyrrr __getitem__ts zCTestPartial.test_setstate_refcount..BadSequence.__getitem__N)rrrrrrrrr BadSequenceqsr)r9rrDrEr)r!rr^rrrtest_setstate_refcountps z"TestPartial.test_setstate_refcountN)rrrrArCrHrNrPrQrRrYrZr[rarhrorvrzrrrrrrrrrrrrrrr%<s2        $r%z requires the C _functools modulec@s<eZdZerejZGdddZddZddZddZd S) TestPartialCc@seZdZddZddZdS)zTestPartialC.AllowPicklecCs|Sr rrGrrr __enter__sz"TestPartialC.AllowPickle.__enter__cCsdSNFrr!rvaluetbrrr__exit__sz!TestPartialC.AllowPickle.__exit__N)rrrrrrrrrrsrc Cs|jtddddd}|tt|dt|tt|dd|tt|d tddd|t}z|`Wnt yvYn 0| d dS) Nr&r'r(r)r*rrrBrz-partial object allowed __dict__ to be deleted) r9rrDAttributeErrorsetattrr>r=hexrrErFr?rrrtest_attributes_unwritables  z'TestPartialC.test_attributes_unwritablecCsh|t}d|jd<t|}|d||d||t|Wdn1sZ0YdS)NriZ1234z'value')r9rrr|rrDrE)r!r@rrrr'test_manually_adding_non_string_keywords     z4TestPartialC.test_manually_adding_non_string_keywordcsP|tGfdddt}dgj|<t}|d||d|dS)NcseZdZfddZdS)z@TestPartialC.test_keystr_replaces_value..MutatesYourDictcsdgj|<dS)NZsth2astr)rrGr@rr__str__s zHTestPartialC.test_keystr_replaces_value..MutatesYourDict.__str__N)rrrrrrrrMutatesYourDictsrZsthrz['sth'])r9rrrr|r)r!rrrrrtest_keystr_replaces_values   z'TestPartialC.test_keystr_replaces_valueN) rrrrr9rrrrrrrrrs  rc@s eZdZejZGdddZdS) TestPartialPyc@s$eZdZddZddZddZdS)zTestPartialPy.AllowPicklecCstdt|_dS)Nr)rr_cmrGrrr__init__sz"TestPartialPy.AllowPickle.__init__cCs |jSr )rrrGrrrrsz#TestPartialPy.AllowPickle.__enter__cCs|j|||Sr )rrrrrrrsz"TestPartialPy.AllowPickle.__exit__N)rrrrrrrrrrrsrN)rrrrr9rrrrrrsrc@s eZdZdS)CPartialSubclassNrrrrrrsrc@s eZdZdS)PyPartialSubclassNrrrrrrsrc@seZdZereZdZdS)TestPartialCSubclassN)rrrrrr9rvrrrrrsrc@seZdZeZdS)TestPartialPySubclassN)rrrrr9rrrrrsrc@szeZdZGdddeZeZddZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZdS)TestPartialMethodc@seZdZeeZeedZejeddZejedddZ ejedddZ eedZ eej ed d d Z eeed Zejeed dZdS)zTestPartialMethod.Ar&r'rJr-r.rLr!rrIr2rK rMN)rrrr partialmethodrnothing positionalrboth spec_keywordsrur9 over_partial staticmethodstatic classmethodclsrrrrAs   rcCsz||j|jfif||jd|jdfif||jjdd|jfddif||jjddd|jdfddif||j|jdfif||jd|jddfif||jjdd|jdfddif||jjddd|jddfddif||j|jfddif||jd|jdfddif||jjdd|jfdddf||jjddd|jdfdddf||j|jd fd d if||jd|jd dfd d if||jjdd|jd fd dd f||jjddd|jd dfd dd f||jj|jddd|jd dfd dd f||j|jfddd fdS)NrIrrr2r&r+r')r+r2r-r,r.r1r)r<r+rrrrrrrGrrrrQs$"& $("$( $&*.z'TestPartialMethod.test_arg_combinationscCs||j|jddfif||jd|jdddfif||jjdd|jddfddif||jjddd|jdddfddif||jj|jddd|jdddfddifdS)Nr&rIrrKrrM)r<r+rurrGrrr test_nesteds "&*zTestPartialMethod.test_nestedcCs||j|jdfddif||jd|jddfddif||jjdd|jdfdddf||jjddd|jddfdddf||jj|jddd|jddfdddfdS)NrKr2rrIrrr2rM)r<r+rrrGrrrtest_over_partials  $&*z#TestPartialMethod.test_over_partialcCs`|j}||jj|||jj|||jj|||jj|j||jjj|jdSr )r+rr__self__rurrrr!objrrrtest_bound_method_introspection s z1TestPartialMethod.test_bound_method_introspectioncCsf|j}|t|jd|t|jd|t|jd|t|jd|t|jjddS)Nr)r assertFalsehasattrrrurrr+rrrrtest_unbound_method_retrievals z/TestPartialMethod.test_unbound_method_retrievalc Cs.|j|jfD]}|j|d||dif||ddif||jdddddif||jddddddif|||jfddif||d|jdfddif||jdd |jfddd f||jddd |jdfddd fWdq 1s0Yq dS) Nr)rrI)rrIrrrMrrr)rr+subTestr<rrrrrrtest_descriptorss "z"TestPartialMethod.test_descriptorscCsL||jjdd|jfddif||jj|jdd|jfddifdS)Nr-rJr+)r<r+rrrGrrrtest_overriding_keywords)s"z*TestPartialMethod.test_overriding_keywordscCs|t Gdddt}Wdn1s00Y|tGddd}Wdn1sh0Y|tGddd}Wdn1s0YdS)Nc@seZdZeddZdS).TestPartialMethod.test_invalid_args..BNr&rrrrrmethodrrrrB/src@seZdZeZdS)rNrrrrrr2sc@seZdZejeddZdS)rr&)rr+N)rrrrrrrrrrrr5s)rDrEr)r!rrrrtest_invalid_args-s  . , z#TestPartialMethod.test_invalid_argscCs$|tt|jddtdS)Nrz#functools.partialmethod({}, 3, b=4))r<r|varsrformatrrGrrrr8szTestPartialMethod.test_reprcCslGdddtj}||jj||jj|jj|jj|jj |jj |jj fD]}| t |ddqPdS)Nc@s&eZdZejddZeedZdS)z1TestPartialMethod.test_abstract..AbstractcSsdSr rr!r6r]rrradd?sz5TestPartialMethod.test_abstract..Abstract.addrIN) rrrabcabstractmethodrrradd5rrrrAbstract=s r__isabstractmethod__F)rABCMetar:rrrrrrrrurrrf)r!rrrrr test_abstract<s &zTestPartialMethod.test_abstractcCs.dd}t|d}||d|dddS)NcSs||Sr rr*rrrr^Lsz1TestPartialMethod.test_positional_only..fr&r')rr9r<rgrrrtest_positional_onlyKs z&TestPartialMethod.test_positional_onlyN)rrrrrr+rQrrrrrrrrrrrrrrrs  rc@seZdZejejfddZddZddZe e j j dkdd d Zd d Zd dZddZeje e j j dkdddZdS)TestUpdateWrapperc Cs|D]}|t||t||q|D]H}t||}t||}|D]*}|dkrX|dkrXqB|||||qBq&||j|dS)Nr __wrapped__)rrfr) r!wrapperwrappedassignedupdatedr Z wrapper_attrZ wrapped_attrrrrr check_wrapperUs  zTestUpdateWrapper.check_wrappercCs<dddd}d|_d|_ddd d }t||||fS) NThis is a new annotationrJcSsdSr rrJrrrr^isz,TestUpdateWrapper._default_update..fThis is also a testzThis is a bald faced liezThis is the prior annotationrLcSsdSr rrLrrrrnsz2TestUpdateWrapper._default_update..wrapper)rrrupdate_wrapperr!r^rrrr_default_updatehs  z!TestUpdateWrapper._default_updatecCsv|\}}|||||j|||jd||j|j||jd||jdd| d|jdS)Nr^rr+rr,) rrrrr<rrr__annotations__ assertNotInr!rr^rrrtest_default_updatess  z%TestUpdateWrapper.test_default_updater')Docstrings are omitted with -O2 and abovecCs|\}}||jddSNzThis is a testrr<__doc__r rrrtest_default_update_doc}s z)TestUpdateWrapper.test_default_update_doccCsdd}d|_dd}t||dd|||dd||jd||j|j||jd||j i| t |ddS) NcSsdSr rrrrrr^sz+TestUpdateWrapper.test_no_update..frcSsdSr rrrrrrsz1TestUpdateWrapper.test_no_update..wrapperrrr) rrrrr<rassertNotEqualrrrrrrrrrtest_no_updatesz TestUpdateWrapper.test_no_updatecCsdd}d|_tdddd|_dd }i|_d }d }t|||||||||||jd ||j |j ||j d||jd||j|jdS) NcSsdSr rrrrrr^sz2TestUpdateWrapper.test_selective_update..fThis is a different testr&r'r-r4cSsdSr rrrrrrsz8TestUpdateWrapper.test_selective_update..wrapperr dict_attrr) rr=rrrrr<rrrrr!r^rassignupdaterrrtest_selective_updatesz'TestUpdateWrapper.test_selective_updatecCsdd}dd}i|_d}d}t|||||d|j||ji|`|t t||||Wdn1s~0Yd|_|t t||||Wdn1s0YdS) NcSsdSr rrrrrr^sz4TestUpdateWrapper.test_missing_attributes..fcSsdSr rrrrrrsz:TestUpdateWrapper.test_missing_attributes..wrapperrrrr&)rrrrrr<rDrrrrrtest_missing_attributess . z)TestUpdateWrapper.test_missing_attributescCsFdd}t|t||jd||jd||jidS)NcSsdSr rrrrrrsz6TestUpdateWrapper.test_builtin_update..wrapperrzmax() rrrr<rr:r startswithr)r!rrrrtest_builtin_updates  z%TestUpdateWrapper.test_builtin_updateN)rrrrWRAPPER_ASSIGNMENTSWRAPPER_UPDATESrrr unittestskipIfr flagsoptimizerrrrrZrequires_docstringsrrrrrrSs"    rc@sHeZdZddZddZeejj dkdddZ d d Z d d Z d S) TestWrapscCs.dd}d|_d|_t|dd}||fS)NcSsdSr rrrrrr^sz$TestWraps._default_update..frzThis is still a bald faced liecSsdSr rrrrrrsz*TestWraps._default_update..wrapper)rrrwrapsrrrrrs  zTestWraps._default_updatecCsH|\}}|||||jd||j|j||jddS)Nr^r)rrr<rrrr rrrr s   zTestWraps.test_default_updater'r cCs|\}}||jddSr r )r!r_rrrrs z!TestWraps.test_default_update_doccCstdd}d|_t|dddd}|||dd||jd||j|j||jd| t |ddS) NcSsdSr rrrrrr^sz#TestWraps.test_no_update..frrcSsdSr rrrrrrsz)TestWraps.test_no_update..wrapperrr) rrr#rr<rrrrrrrrrrrs  zTestWraps.test_no_updatecCsdd}d|_tdddd|_dd }d }d }t||||d d }|||||||jd||j |j ||j d||jd||j|jdS)NcSsdSr rrrrrr^sz*TestWraps.test_selective_update..frr&r'r-r4cSs i|_|Sr r)r^rrr add_dict_attrsz6TestWraps.test_selective_update..add_dict_attrrrcSsdSr rrrrrrsz0TestWraps.test_selective_update..wrapperr) rr=rrr#rr<rrrr)r!r^r%rrrrrrrs  zTestWraps.test_selective_updateN) rrrrr rrr r r!rrrrrrrr"s  r"c@seZdZddZddZdS) TestReducec CsGddd}dd}|||gddd|||dd ggd d ggggd ||d dtdddd||ddtdddd||||dd||||ddd||||ddd|t|j|t|jdd|t|jddd||ddd||dddd|t|jdd|t|j|g|t|j|d|t|j|d|t|j|tGddd}|t|j|||||gdd|||gddGdd d }|t|jd|dS)!Nc@s$eZdZddZddZddZdS)z'TestReduce.test_reduce..SquarescSs||_g|_dSr )rsofar)r!rrrrrsz0TestReduce.test_reduce..Squares.__init__cSs t|jSr )lenr'rGrrrr sz/TestReduce.test_reduce..Squares.__len__cSsRd|kr|jksntt|j}||krH|j|||d7}q&|j|S)Nrr&)rrr(r'append)r!inrrrr s   z3TestReduce.test_reduce..Squares.__getitem__N)rrrrrrrrrrSquaressr,cSs||Sr rr\rrrrsz#TestReduce.test_reduce..addr4rirr+r2rMw)r+r2rMr-cSs||Sr rr\rrrr7r8z(TestReduce.test_reduce..r'rr&icSs||Sr rr\rrrr7r8lhr(ir*1)r/r/rc@seZdZddZdS)z/TestReduce.test_reduce..TestFailingItercSstdSr  RuntimeErrorrGrrr__iter__/sz8TestReduce.test_reduce..TestFailingIter.__iter__N)rrrr3rrrrTestFailingIter.sr4c@seZdZddZdS)z&TestReduce.test_reduce..BadSeqcSstdSr ) ValueError)r!indexrrrr7sz2TestReduce.test_reduce..BadSeq.__getitem__N)rrrrrrrrBadSeq6sr7)r<reducerlrDrErr2r5)r!r,rr4r7rrr test_reduces> zTestReduce.test_reducecCsGddd}ddlm}||||dd||||ddd|t|j||d||||ddd||||d d||||d ddd d d d }||||d |dS)Nc@seZdZddZddZdS)z5TestReduce.test_iterator_usage..SequenceClasscSs ||_dSr r+)r!r+rrrr>sz>TestReduce.test_iterator_usage..SequenceClass.__init__cSs&d|kr|jkrnn|StdSNr)r+rr!r*rrrr@szATestReduce.test_iterator_usage..SequenceClass.__getitem__N)rrrrrrrrr SequenceClass=sr=r)rrIr(r/4r&r'r-)ZoneZtwoZthreeri)operatorrr<r8rDrErmkeys)r!r=rrMrrrtest_iterator_usage<s  zTestReduce.test_iterator_usageN)rrrr9rArrrrr&s8r&c@seZdZerejZdS) TestReduceCN)rrrrr8rrrrrBRsrBc@seZdZeejZdS) TestReducePyN)rrrrrr8rrrrrCXsrCc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS) TestCmpToKeycCsdd}||}||d|d||d|d||d|ddd}||}||d|d||d |d ||d |d ||d |d dS) NcSs||k||kSr rr\rrrcmp1_sz*TestCmpToKey.test_cmp_to_key..cmp1r-r&cSst|t|Sr rdr\rrrcmp2fsz*TestCmpToKey.test_cmp_to_key..cmp2g@4r'Z35) cmp_to_keyr< assertGreaterZassertGreaterEqualZ assertLessassertLessEqualr)r!rErrGrrrtest_cmp_to_key^s  zTestCmpToKey.test_cmp_to_keycCsdd}|j|d}||dd|dd||dd|dd|ttf|ddkWdn1st0Y|ttfd|dkWdn1s0Y|t|}Wdn1s0Y|t||d}Wdn1s0Y||}|t|Wdn1sT0Y|t|ddWdn1s0YdS)NcSs||k||kSr rr\rrrrEosz4TestCmpToKey.test_cmp_to_key_arguments..cmp1mycmpr-rr&)rIr<rJrDrErr!rErrrrtest_cmp_to_key_argumentsns" ** & ,  & z&TestCmpToKey.test_cmp_to_key_argumentscsdd}||}|t |d|dkWdn1sB0YGdddfdd}|t |d|dkWdn1s0YdS)NcSstdSr r_r\rrrrEsz'TestCmpToKey.test_bad_cmp..cmp1r-r&c@seZdZddZdS)z)TestCmpToKey.test_bad_cmp..BadCmpcSstdSr rQr rrr__lt__sz0TestCmpToKey.test_bad_cmp..BadCmp.__lt__N)rrrrRrrrrBadCmpsrScsSr rr\rSrrrEs)rIrDr_rOrrTr test_bad_cmps  .  zTestCmpToKey.test_bad_cmpcCs*dd}|j|d}||djddS)NcSs||k||kSr rr\rrrrEsz)TestCmpToKey.test_obj_field..cmp1rM2)rIr<rrOrrrtest_obj_fields zTestCmpToKey.test_obj_fieldcCs.dd}|ttd||dgddS)NcSs||Sr rr\rrrrNsz)TestCmpToKey.test_sort_int..mycmprIr)r.r-r'r&r)r<sortedrlrI)r!rNrrr test_sort_intszTestCmpToKey.test_sort_intcCs@dd}gd}t|||d}|dd|DgddS)NcSs"t|t|}}||k||kSr rFr\rrrrNsz-TestCmpToKey.test_sort_int_str..mycmp) rI3rKr'0r0r.Z10r&rXcSsg|] }t|qSrrF)r}rrrrrr8z2TestCmpToKey.test_sort_int_str..) rr&r&r'r-r.rIrKr()rYrIr<)r!rNvaluesrrrtest_sort_int_strs zTestCmpToKey.test_sort_int_strcCs<dd}||}|d}|tt|||tjjdS)NcSs||Sr rr\rrrrNsz%TestCmpToKey.test_hash..mycmpr()rIrDrEhashZassertNotIsInstance collectionsrHashable)r!rNrkrrr test_hashs  zTestCmpToKey.test_hashN) rrrrLrPrUrWrZr^rcrrrrrD\s rDc@seZdZerejZdS) TestCmpToKeyCN)rrrrrIrrrrrdsrdc@seZdZeejZdS)TestCmpToKeyPyN)rrrrrrIrrrrresrec@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)TestTotalOrderingcCstjGddd}||d|dk||d|dk||d|dk||d|dk||d|dk||d|dk||d|dkdS)Nc@s$eZdZddZddZddZdS)z3TestTotalOrdering.test_total_ordering_lt..AcSs ||_dSr rr!rrrrrsz.A.__init__cSs |j|jkSr rgr rrrrRsz:TestTotalOrdering.test_total_ordering_lt..A.__lt__cSs |j|jkSr rgr rrr__eq__sz:TestTotalOrdering.test_total_ordering_lt..A.__eq__NrrrrrRrirrrrrsrr&r'rtotal_orderingr:rr!rrrrtest_total_ordering_ltsz(TestTotalOrdering.test_total_ordering_ltcCstjGddd}||d|dk||d|dk||d|dk||d|dk||d|dk||d|dk||d|dkdS)Nc@s$eZdZddZddZddZdS)z3TestTotalOrdering.test_total_ordering_le..AcSs ||_dSr rgrhrrrrsz.A.__init__cSs |j|jkSr rgr rrr__le__sz:TestTotalOrdering.test_total_ordering_le..A.__le__cSs |j|jkSr rgr rrrrisz:TestTotalOrdering.test_total_ordering_le..A.__eq__N)rrrrrorirrrrrsrr&r'rkrmrrrtest_total_ordering_lesz(TestTotalOrdering.test_total_ordering_lecCstjGddd}||d|dk||d|dk||d|dk||d|dk||d|dk||d|dk||d|dkdS)Nc@s$eZdZddZddZddZdS)z3TestTotalOrdering.test_total_ordering_gt..AcSs ||_dSr rgrhrrrrsz.A.__init__cSs |j|jkSr rgr rrr__gt__sz:TestTotalOrdering.test_total_ordering_gt..A.__gt__cSs |j|jkSr rgr rrrrisz:TestTotalOrdering.test_total_ordering_gt..A.__eq__N)rrrrrqrirrrrrsrr&r'rkrmrrrtest_total_ordering_gtsz(TestTotalOrdering.test_total_ordering_gtcCstjGddd}||d|dk||d|dk||d|dk||d|dk||d|dk||d|dk||d|dkdS)Nc@s$eZdZddZddZddZdS)z3TestTotalOrdering.test_total_ordering_ge..AcSs ||_dSr rgrhrrrrsz.A.__init__cSs |j|jkSr rgr rrr__ge__sz:TestTotalOrdering.test_total_ordering_ge..A.__ge__cSs |j|jkSr rgr rrrrisz:TestTotalOrdering.test_total_ordering_ge..A.__eq__N)rrrrrsrirrrrrsrr&r'rkrmrrrtest_total_ordering_gesz(TestTotalOrdering.test_total_ordering_gecCstjGdddt}||d|dk||d|dk||d|dk||d|dk||d|dk||d|dkdS)Nc@s eZdZdS)z=TestTotalOrdering.test_total_ordering_no_overwrite..ANrrrrrrsrr&r')rrlrdr:rmrrr test_total_ordering_no_overwritesz2TestTotalOrdering.test_total_ordering_no_overwritecCsB|t$tjGddd}Wdn1s40YdS)Nc@s eZdZdS)z7TestTotalOrdering.test_no_operations_defined..ANrrrrrr sr)rDr5rrlrmrrrtest_no_operations_defined s z,TestTotalOrdering.test_no_operations_definedc stjGfdddtjGfdddtjGfdddtjGfdddtjGfd d d |d F|td d kWdn1s0YWdn1s0Y|dL|t ddkWdn1s0YWdn1s60Y|dL|t d d kWdn1s~0YWdn1s0Y|dL|t ddkWdn1s0YWdn1s0Y|dL|t ddkWdn1sN0YWdn1sn0Y|dL|t ddkWdn1s0YWdn1s0Y|dL|t ddkWdn1s0YWdn1s>0Y|dL|t ddkWdn1s0YWdn1s0Y|dL|t ddkWdn1s0YWdn1s0Y|d`d}d}||||t||kWdn1sj0YWdn1s0Y|d`d }d }||||t||kWdn1s0YWdn1s0YdS)!Ncs,eZdZddZfddZfddZdS)zRTestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThancSs ||_dSr rgrhrrrrsz[TestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThan.__init__cst|r|j|jkSdSr isinstancerr ImplementsLessThanrrris  zYTestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThan.__eq__cst|r|j|jkStSr rxrNotImplementedr ryrrrRs  zYTestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThan.__lt__NrrrrrirRrryrrrzs rzcs,eZdZddZfddZfddZdS)zUTestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThancSs ||_dSr rgrhrrrr#sz^TestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThan.__init__cst|r|j|jkSdSrrwr ImplementsGreaterThanrrri%s  z\TestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThan.__eq__cst|r|j|jkStSr r{r r~rrrq)s  z\TestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThan.__gt__N)rrrrrirqrr~rrr!s rcs,eZdZddZfddZfddZdS)zYTestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThanEqualTocSs ||_dSr rgrhrrrr0szbTestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThanEqualTo.__init__cst|r|j|jkSdSrrwr ImplementsLessThanEqualTorrri2s  z`TestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThanEqualTo.__eq__cst|r|j|jkStSr r{r rrrro6s  z`TestTotalOrdering.test_type_error_when_not_implemented..ImplementsLessThanEqualTo.__le__N)rrrrrirorrrrr.s rcs,eZdZddZfddZfddZdS)z\TestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThanEqualTocSs ||_dSr rgrhrrrr=szeTestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThanEqualTo.__init__cst|r|j|jkSdSrrwr ImplementsGreaterThanEqualTorrri?s  zcTestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThanEqualTo.__eq__cst|r|j|jkStSr r{r rrrrsCs  zcTestTotalOrdering.test_type_error_when_not_implemented..ImplementsGreaterThanEqualTo.__ge__N)rrrrrirsrrrrr;s rcs(eZdZddZfddZddZdS)zXTestTotalOrdering.test_type_error_when_not_implemented..ComparatorNotImplementedcSs ||_dSr rgrhrrrrJszaTestTotalOrdering.test_type_error_when_not_implemented..ComparatorNotImplemented.__init__cst|r|j|jkSdSrrwr ComparatorNotImplementedrrriLs  z_TestTotalOrdering.test_type_error_when_not_implemented..ComparatorNotImplemented.__eq__cSstSr )r|r rrrrRPsz_TestTotalOrdering.test_type_error_when_not_implemented..ComparatorNotImplemented.__lt__Nr}rrrrrHs rzLT < 1r&zLT < LErzLT < GTzLE <= LTr'zLE <= GEr-zGT > GEr.zGT > LTrIzGE >= GTrzGE >= LErKz GE when equalrz LE when equalr)rrlrrDrEr<)r!r+r,r)rrrrzrr$test_type_error_when_not_implementedsP     HPPPPPPPP   H   z6TestTotalOrdering.test_type_error_when_not_implementedc CsxttjdD]d}dD]Z}|j||d8tt|}tt||}|||Wdq1sf0YqqdS)Nr&)rRrqrors)rr) rlrrrrf Orderable_LTrrr)r!rr rZ method_copyrrrr|s  zTestTotalOrdering.test_pickleN) rrrrnrprrrtrurvrrrrrrrfs krfc@s$eZdZddZddZddZdS)rcCs ||_dSr rgrhrrrrszOrderable_LT.__init__cCs |j|jkSr rgr rrrrRszOrderable_LT.__lt__cCs |j|jkSr rgr rrrriszOrderable_LT.__eq__Nrjrrrrrsrc@seZdZddZdS) TestCachec s|jjfdd|fddtdDgd||jjddddd||jjd d dd ddS) Ncs$|dkr |S|d|dSNr'r&rr:fibrrrsz!TestCache.test_cache..fibcsg|] }|qSrrr}r+rrrrr8z(TestCache.test_cache..rbrr&r&r'r-rIr r."7Yiyibhitsmissesmaxsizecurrsizer)modulecacher<rl cache_info _CacheInfo cache_clearrGrrr test_caches  zTestCache.test_cacheN)rrrrrrrrrsrc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5S)6TestLRUc sNdd}|jjdd|}|\}}}}||d||d||d||dtd}tdD]6}t|t|} } || | } || | } || | qj|\}}}}|||k|||d||d||\}}}}||d||d||d|| | |\}}}}||d||d||d||j || | | |\}}}}||d||d||d|jdfd d }||j ddtdD]}||dq|d|\}}}}||d||d||d|jdfd d }||j ddtdD]}||dqf|d|\}}}}||d ||d||d|jd fdd }||j d ddD]} ||| | dq|d |\}}}}||d||d ||d dS)NcSs d||SNr-rr\rrrorigszTestLRU.test_lru..origr)rrrIr&cs d7dSNr&r)rrf_cntrrr^szTestLRU.test_lru..fcs d7dSrrrrrrr^sr.r'csd7|dSNr&r(rr5rrrr^s)rKrrKrrKrrrrrrrrrrrKr( ) r lru_cacherr<rlrr:rrrr) r!rr^rrrrdomainr*r6r]actualrVrrrtest_lrus                                   zTestLRU.test_lrucCsz|jjdd}|tt|gdgd||jd||jd||jd||j ddS)NcSs|dSNr'rr5rrrsquaresz(TestLRU.test_lru_no_args..square)r(r)r()dirr&r') rrr<rr>rrrrr)r!rrrrtest_lru_no_argss zTestLRU.test_lru_no_argscs~d|jjddfddtdD]}||d|dq(|jd|dd |jddS) NTr(rcs(d|d}|dkr$r$d|}|S)N.r)Fr)r6rvr^oncerrr^s   z%TestLRU.test_lru_bug_35780..frr)z.20.)rrrlr<rrr!r6rrrtest_lru_bug_35780s  zTestLRU.test_lru_bug_35780cCs>|jdd}|d|dii||jddS)NcSsdSr rr5rrrr^)sz%TestLRU.test_lru_bug_36650..frr&)r)rrr<rrr`rrrtest_lru_bug_36650#s  zTestLRU.test_lru_bug_36650cCs |jjdddd}tj}tjjdd|_tjjdd|_|||dd||jjd|| d |||dd||jjd || d ||d d d ||jjd || d|||dd||jjd|| ddS)Nr&rcSs |d|Srrr\rrrr^7sz*TestLRU.test_lru_hash_only_once..fr)Z return_valueirb)rr&r&r&r')r&r&r&r&rr))r&r'r&r&r-)r&r-r&r&) rrrZmockZMock__mul____hash__r<Z call_countr)r!r^Zmock_intrrrtest_lru_hash_only_once1s"   zTestLRU.test_lru_hash_only_oncecCsRtj}z>|jdtt_dD]}|tdd||qW|t_n|t_0dS)Nr.) rrr&r'r-r-r.rIrr&rKr'r&Zabcdefghijklmn)builtinsr(rrr<)r!Zold_lenr*rrrtest_lru_reentrancy_with_lenTs z$TestLRU.test_lru_reentrancy_with_lencCs6tdd}||ddd||dddS)NcWs|Sr rrrrrr^bsz-TestLRU.test_lru_star_arg_handling..fr&r'rB)rB)rrr<r`rrrtest_lru_star_arg_handling`s z"TestLRU.test_lru_star_arg_handlingcCstjdddd}tjdddd}|t|gWdn1sP0Y|t|gWdn1s0YdS)NrcSsdSr rorrrinfinite_cachensz3TestLRU.test_lru_type_error..infinite_cacher(cSsdSr rrrrr limited_cachersz2TestLRU.test_lru_type_error..limited_cache)rrrDrE)r!rrrrrtest_lru_type_erroris     & zTestLRU.test_lru_type_errorc s|jjddfdd|fddtdDgd||jjddddd ||jjd d dd d dS) Nrcs$|dkr |S|d|dSrrr:rrrr}sz/TestLRU.test_lru_with_maxsize_none..fibcsg|] }|qSrrrrrrrr8z6TestLRU.test_lru_with_maxsize_none..rbrrrrrrr<rlrrrrGrrrtest_lru_with_maxsize_none|s   z"TestLRU.test_lru_with_maxsize_nonec sj|jjdddddD]*}|fddtdDttdq||jjd d d d d dS) NircSs|Sr rr:rrreqsz2TestLRU.test_lru_with_maxsize_negative..eqrTcsg|] }|qSrrrrrrrr8z:TestLRU.test_lru_with_maxsize_negative..ri,r)rrr<rlrrrr<rrrtest_lru_with_maxsize_negatives  ( z&TestLRU.test_lru_with_maxsize_negativec CsdD]}|j|dd}||dd|t}|dWdn1sT0Y||jj|t|dWdq1s0YqdS)NNrcSsd|S)Nrrr*rrrrsz.TestLRU.test_lru_with_exceptions..funcrr+r)rrr<rDr assertIsNone exception __context__)r!rrcmrrrtest_lru_with_exceptionss   & z TestLRU.test_lru_with_exceptionscCsdD]}|jj|dddd}||dd|t|dtd||dd |t|dtd ||dd d|t|dd td||dd d |t|dd td ||jd ||jd qdS) NrTrtypedcSs||Sr rr5rrrrsz+TestLRU.test_lru_with_types..squarer-rg@g"@r5r.)rrr<rrrr)r!rrrrrtest_lru_with_typess zTestLRU.test_lru_with_typesc s|jfdd|fddtdDgd||jjddddd ||jjd d dd d dS) Ncs(|dkr |S|dd|ddSNr'r&r:rr:rrrrsz/TestLRU.test_lru_with_keyword_args..fibcsg|]}|dqSr:rr}Znumberrrrrr8z6TestLRU.test_lru_with_keyword_args..rbrrrrrrrGrrrtest_lru_with_keyword_argss  z"TestLRU.test_lru_with_keyword_argsc s|jjddfdd|fddtdDgd||jjddddd ||jjd d dd d dS) Nrcs(|dkr |S|dd|ddSrrr:rrrrsz.fibcsg|]}|dqSrrrrrrrr8zCTestLRU.test_lru_with_keyword_args_maxsize_none..rbrrrrrrGrrr'test_lru_with_keyword_args_maxsize_nones   z/TestLRU.test_lru_with_keyword_args_maxsize_nonec Csj|jjdddd}||ddddd g||ddd d dg|||jjd dddd dS) Nr(rc[s t|Sr )ritems)rrrrr^sz$TestLRU.test_kwargs_order..fr&r'r*)r+r&)r,r')r,r+rr)rrr<rrr`rrrtest_kwargs_orders   zTestLRU.test_kwargs_ordercCsFdddd}|j|}|jjD]}|t||t||q$dS)NZzomg_annotationZzomgcSsdS)Nr/rrrrrr^sz,TestLRU.test_lru_cache_decoration..f)rrrr<rf)r!r^grrrrtest_lru_cache_decorations z!TestLRU.test_lru_cache_decorationc sd\}ddjj|d\}}}}|dtfddfdd }t}t d z$fd d t |D}t | Wdn1s0Y\}}}}jt ur |||||n |||||||tj|d g}|fdd t |D7}t | Wdn1s0YWt |n t |0dS)N)rI cSs d||Srrr\rrrrsz-TestLRU.test_lru_cache_threaded..origrrcs4dtD]}|d|dqdS)Nr(r)waitrlr<)rbr$)r^mrr!startrrfulls  z-TestLRU.test_lru_cache_threaded..fullcs(dtdD] }qdS)Nr(r')rrlr)r$)r^rrrrclears z.TestLRU.test_lru_cache_threaded..clearư>csg|]}tj|gdqS)targetr threadingThreadr}rbrrrrsz3TestLRU.test_lru_cache_threaded..rcsg|]}tj|gdqSrrrrrrr s)rrrr<rEventr getswitchintervalrsetswitchintervalrl start_threadssetrrKrr) r!r+rrrrrorig_sithreadsr)r^rrrr!rrtest_lru_cache_threadeds>    &      *zTestLRU.test_lru_cache_threadedc s2d\}t|dt|dt|djj|dfdddd|dffddfd d t|D}t||tD]b} d   d   d  d|d|||dfqWdn1s$0YdS) N)rIrKr&rcsdd|SNr(r-)rr5)pauserrr^s z+TestLRU.test_lru_cache_threaded2..frcs:tD],}d|d|dqdSr)rlrr<r)r^rr!rstoprrtests  z.TestLRU.test_lru_cache_threaded2..testcsg|]}tjdqS)rrrrrrr#r8z4TestLRU.test_lru_cache_threaded2..r() rBarrierrrr<rrlrrrreset)r!r+rr*r)r^rrr!rrrrtest_lru_cache_threaded2s$     z TestLRU.test_lru_cache_threaded2csljjddddfddfddtgd D}t|Wdn1s^0YdS) Nr'rcSstdd|S)Ng{Gz?r-)timesleepr5rrrr^/s z+TestLRU.test_lru_cache_threaded3..fcsFj|d&|d||Wdn1s80YdS)N)threadr-)rr<)r*r6)r^r!rrr3sz.TestLRU.test_lru_cache_threaded3..testcs"g|]\}}tj||fdqSrr)r}r*vrrrr6sz4TestLRU.test_lru_cache_threaded3..)r&r'r'r-r')rr enumeraterr)r!rr)r^r!rrtest_lru_cache_threaded3.s     z TestLRU.test_lru_cache_threaded3cs^|jjddddGfddddd|dddS) Nr(rcSs|Sr rr5rrr test_func>sz.TestLRU.test_need_for_rlock..test_funccs*eZdZddZddZfddZdS)z-TestLRU.test_need_for_rlock..DoubleEqcSs ||_dSr r5rrrrrEsz6TestLRU.test_need_for_rlock..DoubleEq.__init__cSs|jSr r5rGrrrrGsz6TestLRU.test_need_for_rlock..DoubleEq.__hash__cs"|jdkrd|j|jkSrr5r DoubleEqrrrriIs  z4TestLRU.test_need_for_rlock..DoubleEq.__eq__N)rrrrrrirrrrr Csr r&r')rrr<rGrrrtest_need_for_rlock;s    zTestLRU.test_need_for_rlockcstGfdddt}|d}|d}|d}|jddD]}|||ddqB|j|j|jfd|jd d D]}|||ddq|j|j|jfd |jd d D]}|||ddqވ|j|j|jfd|jd|j|j|j|j|j|jdS)Ncs$eZdZdZjdddZdS)z"TestLRU.test_lru_method..Xrr'cSs|jd7_|d|Srrrrrrr^Vsz$TestLRU.test_lru_method..X.fN)rrrrrrr^rrGrrXTs r rIrK)rrr'r) r&r'r'r-r&r&r&r'r-r-r()rrr)r.rr'r') r&r'r&r&r&r&r-r'r'r')rr.r)r(r(r'r') r'r&r&r&r&r'r&r-r'r&)rr.rI)rrr'r')rdr<r^rr)r!r r+r,r2r6rrGrtest_lru_methodSs(zTestLRU.test_lru_methodc Cs|j}|jd|j|jfD]d}ttjdD]P}|j||d.tt ||}| ||Wdq,1sr0Yq,qdS)Nrr&)rr) __class__ cached_func cached_methcached_staticmethrlrrrrrr)r!rr^rrrrrrrs zTestLRU.test_picklec Cs|j}dd}|j|d}|jd|j|j|jd|f}|D]F}|j|d&t|}| ||WdqB1s~0YqBdS)NcSs d||Srrr\rrrr|szTestLRU.test_copy..origr'rr) r rr9rrrrrrrr!rrrZfuncsr^rrrrrzs zTestLRU.test_copyc Cs|j}dd}|j|d}|jd|j|j|jd|f}|D]F}|j|d&t |}| ||WdqB1s~0YqBdS)NcSs d||Srrr\rrrrsz#TestLRU.test_deepcopy..origr'rr) r rr9rrrrrrrrrrrrrs zTestLRU.test_deepcopycCs^|jjdddd}||ddd|jjdddd d}||ddddS) Nr'rcSsdSNr&rrrrrr^sz,TestLRU.test_lru_cache_parameters..fFrrTcSsdSrrrrrrr^s)rrr<cache_parametersr`rrrtest_lru_cache_parameterss    z!TestLRU.test_lru_cache_parameterscs~jjdd}Gfddd}t|t|jt|jg}|D]}|qF~~t|D]} |qhdS)NcSs|Sr rr5rrr test_functionsz9TestLRU.test_lru_cache_weakrefable..test_functioncs4eZdZjjddZejjfddZdS)z-TestLRU.test_lru_cache_weakrefable..AcSs||fSr rrrrr test_methodsz9TestLRU.test_lru_cache_weakrefable..A.test_methodcs|fSr rr5rGrrtest_staticmethodsz?TestLRU.test_lru_cache_weakrefable..A.test_staticmethodN)rrrrrrrrrrGrrrs  r) rrweakrefrefrrZassertIsNotNonegcZcollectr)r!rrZrefsrrrGrtest_lru_cache_weakrefables    z"TestLRU.test_lru_cache_weakrefableN)rrrrrrrrrrrrrrrrrrrrrrr r rrrrrrrrrrs4Y #    0    rcCs d||Srrr\rrrpy_cached_funcsrcCs d||Srrr\rrr c_cached_funcsrc@s:eZdZeZefZeddZe eddZ dS) TestLRUPycCs d||SrrrrrrrszTestLRUPy.cached_methcCs d||Srrr\rrrrszTestLRUPy.cached_staticmethN) rrrrrrrrrrrrrrrrs rc@s:eZdZeZefZeddZe eddZ dS)TestLRUCcCs d||SrrrrrrrszTestLRUC.cached_methcCs d||Srrr\rrrrszTestLRUC.cached_staticmethN) rrrrrrrrrrrrrrrr s r c@seZdZddZddZddZddZee d e j d d Z d d Z ddZddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*S)+TestSingleDispatchcCsZtjdd}dd}|t|||dd||dd||gd ddS) NcSsdSNrcrrrrrrsz3TestSingleDispatch.test_simple_overloads..gcSsdS)Nintegerrrrrrg_intsz7TestSingleDispatch.test_simple_overloads..g_intrkrcr&r#r&r'r-)rsingledispatchregisterrdr<r!rr$rrrtest_simple_overloadss  z(TestSingleDispatch.test_simple_overloadscCstjdd}Gddd}Gddd|}Gddd|}Gd d d ||}d d }d d}|||||||||d|||d|||d|||ddS)NcSsdSr"rrrrrrsz&TestSingleDispatch.test_mro..gc@s eZdZdS)z&TestSingleDispatch.test_mro..ANrrrrrrsrc@s eZdZdS)z&TestSingleDispatch.test_mro..CNrrrrrCsr*c@s eZdZdS)z&TestSingleDispatch.test_mro..BNrrrrrrsrc@s eZdZdS)z&TestSingleDispatch.test_mro..DNrrrrrDsr+cSsdS)NrrrJrrrg_Asz(TestSingleDispatch.test_mro..g_AcSsdS)NrrrLrrrg_Bsz(TestSingleDispatch.test_mro..g_B)rr&r'r<)r!rrr*rr+r,r-rrrtest_mros   zTestSingleDispatch.test_mrocCsntjdd}|tdd}||dd||dd||t|||t|tdS) NcSsdSr"rrrrrrsz5TestSingleDispatch.test_register_decorator..gcSs d|fS)Nzint %srrrrrr$sz9TestSingleDispatch.test_register_decorator..g_intrircrzint 12) rr&r'rdr<rdispatchrrkr(rrrtest_register_decorators  z*TestSingleDispatch.test_register_decoratorcCs:tjdd}||jdtjjdkr6||jddS)NcSsdS)NZTestrrrrrrsz6TestSingleDispatch.test_wrapping_attributes..grr'z Simple test)rr&r<rr r r!r)r!rrrrtest_wrapping_attributess   z+TestSingleDispatch.test_wrapping_attributeszrequires _decimalcCstjdd}|tjdd}td}td}|||d|||d|tjd d}|||d |||ddS) NcSsdSr"rrrrrrsz,TestSingleDispatch.test_c_classes..gcSs|jSr rrrrrr$ sz,TestSingleDispatch.test_c_classes.._Exponent < EminNumber got rounded)r2)r3cSsdS)NToo small to care.rrrrrr$'sr4)rr&r'r ZDecimalExceptionZ SubnormalZRoundedr<)r!rr$subnZrndrrrtest_c_classess       z!TestSingleDispatch.test_c_classescCstj}tj}|j|j|j|jg}t|D]6}|t |}| |t |j|j|j |j |j |jtgq(|j|j|jtjg}t|D]:}|tj|}| |tj|j|j|j |j |j |jtgq||j|j tg}t|D]6}|tj|j |jtg}| |tjt |j |jtgqGdddtj}|j||j|jg}t|D]J}|||}| |||j|j|jtjt |j|j|j |j |j |jtg q8Gdddtj}|j |j|j|jg}t|D]>}|||}| |||jtjt |j|j |j |j |jtg qdS)Nc@s eZdZdS)z.TestSingleDispatch.test_compose_mro..DNrrrrrr+Ksr+c@seZdZddZdS)z.TestSingleDispatch.test_compose_mro..CcSsdSr rrGrrr__call__Zsz7TestSingleDispatch.test_compose_mro..C.__call__Nrrrr7rrrrr*Ysr*)r`rr _compose_mroSequenceMutableMappingMappingSetrr=r< CollectionSizedIterable Containerr OrderedDictChainMaprk defaultdictMutableSequencer' ReversibleCallable)r!r2mrobasesZhaystackrr+r*rrrtest_compose_mro-sP               z#TestSingleDispatch.test_compose_mrocCs~tj}ddi}gd}tdh}t|}d}tjdd}|||d|||d|||d|||d|||d||jdd|||d |||d |||d |||d |||d ||j d d|||d |||d |||d |||d |||d |tj d d|||d |||d |||d |||d |||d ||j d d|||d |||d|||d |||d |||d ||j dd|||d |||d|||d|||d |||d ||j dd|||d |||d|||d|||d |||d ||jdd|||d |||d|||d|||d |||d||jdd|||d |||d|||d|||d|||d|tdd|||d|||d|||d|||d|||d|tdd|||d|||d|||d|||d|||d|tdd|||d|||d|||d|||d|||d|tdd|||d|||d|||d|||d|||d|tdd|||d|||d|||d|||d|||ddS) Nr+r,r%cSsdSr"rrrrrrjsz/TestSingleDispatch.test_register_abc..grccSsdSNsizedrrrrrr7rr8z6TestSingleDispatch.test_register_abc..rLcSsdSNmutablemappingrrrrrr7xr8rNcSsdS)NZchainmaprrrrrr7~r8cSsdS)Nmutablesequencerrrrrr7r8rOcSsdS)N mutablesetrrrrrr7r8rPcSsdSNmappingrrrrrr7r8cSsdSNsequencerrrrrr7r8rTcSsdSNrrrrrrr7r8rcSsdSNr=rrrrrr7r8r=cSsdSNrrrrrrr7r8rcSsdS)N concrete-setrrrrrr7r8rXcSsdS)N frozen-setrrrrrr7r8rYcSsdS)Nrrrrrrr7r8r)r`rr frozensetrr&r<r'r?r;rCrE MutableSetr<r:r=r=rrr)r!r2rMlrr^trrrrtest_register_abccs  z$TestSingleDispatch.test_register_abcc Cstj}tj}Gdddt}Gddd|}|jjGdddt}Gdddt}Gd d d |||}||j|||j||j|tg }t |j|j|jgD]} | ||| d |q|j |j|j|j|j g} | ||| d |dS) Nc@s eZdZdS)z)TestSingleDispatch.test_c3_abc..ANrrrrrrsrc@seZdZddZdS)z)TestSingleDispatch.test_c3_abc..BcSsdSr;rrGrrrrsz1TestSingleDispatch.test_c3_abc..B.__len__Nrrrrrrrrrsrc@s eZdZdS)z)TestSingleDispatch.test_c3_abc..CNrrrrrr*sr*c@s eZdZdS)z)TestSingleDispatch.test_c3_abc..DNrrrrrr+sr+c@seZdZddZdS)z)TestSingleDispatch.test_c3_abc..XcSsdSr rrGrrrr7sz2TestSingleDispatch.test_c3_abc..X.__call__Nr8rrrrr sr )abcs) r`rr_c3_mrorrAr'rGr?rr<r<r@) r!r2rHrrr*r+r rVr`Z many_abcsrrr test_c3_abcszTestSingleDispatch.test_c3_abccCslGdddt}Gddd|d}Gddd|}tjdd }||d d }|}|||d dS) Nc@seZdZddZdS)z1TestSingleDispatch.test_false_meta..MetaAcSsdSr;rrGrrrrsz9TestSingleDispatch.test_false_meta..MetaA.__len__Nr_rrrrMetaAsrcc@s eZdZdS)z-TestSingleDispatch.test_false_meta..ANrrrrrrsr metaclassc@s eZdZdS)z.TestSingleDispatch.test_false_meta..AANrrrrrAAsrfcSsdS)Nzbase ArrJrrrfunsz/TestSingleDispatch.test_false_meta..funcSsdS)Nfun ArrJrrrr$sz-TestSingleDispatch.test_false_meta.._rh)rrr&r'r<)r!rcrrfrgr$aarrrtest_false_metas  z"TestSingleDispatch.test_false_metacCstj}tjdd}Gddd|j}|}|||d||jdd||jdd||jd d||j d d|||d |j||||d |j||||d |j ||||d Gd dd}|}|||d|j||||d|j|| t }||Wdn1s^0Y| t |jdGddd|j}|} ||| d |j|||| d |j |||| d tjdd} | |jdd} | |jdd} | t "} | tddWdn1sD0Y| t | jdGdddtj} |j| tjdd}||jdd} ||jdd} | }|||d Gd!d"d"}Gd#d$d$||j}|}|| |d |j||| |d Gd%d&d&}|}|| |d |j|| t }| |Wdn1sx0Y| t |jdGd'd(d(|j|}tjd)d*}||d+d} ||jd,d} |}|||d-|j||||d.dS)/NcSsdSr"rargrrrrsz0TestSingleDispatch.test_mro_conflicts..gc@seZdZddZdS)z0TestSingleDispatch.test_mro_conflicts..OcSsdSr;rrGrrrrsz8TestSingleDispatch.test_mro_conflicts..O.__len__Nr_rrrrOsrmrccSsdS)Niterablerrkrrrr7r8z7TestSingleDispatch.test_mro_conflicts..cSsdSN containerrrkrrrr7r8cSsdSrKrrkrrrr7r8cSsdSrUrrkrrrr7r8rLrc@s eZdZdS)z0TestSingleDispatch.test_mro_conflicts..PNrrrrrPsrqrn)z]Ambiguous dispatch: or z]Ambiguous dispatch: or c@seZdZddZdS)z0TestSingleDispatch.test_mro_conflicts..QcSsdSr;rrGrrrrsz8TestSingleDispatch.test_mro_conflicts..Q.__len__Nr_rrrrQsrrcSsdSr"rrkrrrhsz0TestSingleDispatch.test_mro_conflicts..hcSsdSrKrrkrrrr$sz0TestSingleDispatch.test_mro_conflicts.._cSsdSrorrkrrrr$ scSsdSr;rrrrrr7(r8)zZAmbiguous dispatch: or zZAmbiguous dispatch: or c@s eZdZdS)z0TestSingleDispatch.test_mro_conflicts..RNrrrrrR0srtcSsdSr"rrkrrrr*3sz0TestSingleDispatch.test_mro_conflicts..icSsdSrQrrkrrrr$6scSsdSrSrrkrrrr$9srTc@s eZdZdS)z0TestSingleDispatch.test_mro_conflicts..SNrrrrrS>sruc@seZdZddZdS)z0TestSingleDispatch.test_mro_conflicts..TcSsdSr;rrGrrrrAsz8TestSingleDispatch.test_mro_conflicts..T.__len__Nr_rrrrT@srvc@seZdZddZdS)z0TestSingleDispatch.test_mro_conflicts..UcSsdSr;rrGrrrrHsz8TestSingleDispatch.test_mro_conflicts..U.__len__Nr_rrrrUGsrwc@seZdZddZdS)z0TestSingleDispatch.test_mro_conflicts..VcSsdSr;rrGrrrrYsz8TestSingleDispatch.test_mro_conflicts..V.__len__Nr_rrrrVXsrxcSsdSr"rrkrrrj[sz0TestSingleDispatch.test_mro_conflicts..jcSsdS)Nrrrkrrrr$^scSsdSrorrkrrrr$asrrp)r`rrr&r?r<r'r@rAr=rDr2rrkrrDrEr;)r!r2rrmrrqr@Zre_onerrqrsr$Zre_twortr*rrurvr]rwuZre_threerxryrrrrtest_mro_conflictss       (        2         (     z%TestSingleDispatch.test_mro_conflictsc s^ddlm}ddl}Gfddd|t|dfddtj}tjdd }i}g}|t d|||d |t d |j g|j t g|j t |jt|||d |t d |j g|j t tg|j t |jt|j t|jt|j t j t|||d |||d |j tt g|j t tg|td d|j tt g|t d|||d |t d |j tt g|j t tt g|j t tt |j|||d|t d |j tt g|j t tt tg|j ttt|jGddd}|j||||d |||d|j tt t tg|j t tt tg||jdd|t d|||d|t d |j tt t tg|j t tt tt g|||d|t d |j tt t tg|j t tt tt tg|||d|||d|j tt t ttt g|j t tt tt tg|t|t |j tt t ttt tt g|j t tt tt tg|j||t d |||d|t d ||jdd|t d|||d|t d |||d|t d |t dd|||d|||d||t dWdn1sP0YdS)Nr)UserDictcs6eZdZfddZddZddZddZZS) z?TestSingleDispatch.test_cache_invalidation..TracingDictcs&t|j|i|g|_g|_dSr )superrset_opsget_ops)r!rr) TracingDictr rrroszHTestSingleDispatch.test_cache_invalidation..TracingDict.__init__cSs|j|}|j||Sr )rnrr))r!rresultrrrrss  zKTestSingleDispatch.test_cache_invalidation..TracingDict.__getitem__cSs|j|||j|<dSr )rr)rn)r!rrrrr __setitem__ws zKTestSingleDispatch.test_cache_invalidation..TracingDict.__setitem__cSs|jdSr )rnrrGrrrrzszETestSingleDispatch.test_cache_invalidation..TracingDict.clear)rrrrrrr __classcell__r)r)r rrnsrWeakKeyDictionarycsSr rr)tdrrr7~r8z.cSsdSr"rrkrrrrsz5TestSingleDispatch.test_cache_invalidation..grcr&r'cSsdSrWrrkrrrr7r8rc@s eZdZdS)z5TestSingleDispatch.test_cache_invalidation..XNrrrrrr sr cSsdSrKrrkrrrr7r8rLcSsdSrMrrkrrrr7r8rNcSsdSrVrrkrrrr7r8r=)r`r}rrZ swap_attrrrr&r<r(rrr=rnregistryrrr' _find_implr;r?r/r[ _clear_cache)r!r}rr2rrMr\r r)rrrtest_cache_invalidationjs          z*TestSingleDispatch.test_cache_invalidationcCstjdd}|jtjjddd}|jdddd}||dd||d d id ||gd d ||d d ||dd |tGddd}||dddS)NcSsdSr"rrkrrrr*sz.TestSingleDispatch.test_annotations..irkcSsdSrQrrkrrrr$s.TestSingleDispatch.test_annotations.._zcollections.abc.SequencecSsdSrSrrkrrrr$srcr+r&rRr%rTrkc@seZdZddZddZdS)rcSs ||_dSr rkr!rlrrrrsz7TestSingleDispatch.test_annotations.._.__init__cSs |j|kSr rkr rrrrisz5TestSingleDispatch.test_annotations.._.__eq__N)rrrrrirrrrr$sr$)rr&r'r`rr<r<rk)r!r*r$rrrtest_annotationss z#TestSingleDispatch.test_annotationscCsGddd}|}|d||jd|}|t|d|d||jd|}|t|d|d||jd |}|t|ddS) Nc@s>eZdZejddZeeddZee ddZdS)z2TestSingleDispatch.test_method_register..AcSs d|_dSr"rkrrrrr]sz4TestSingleDispatch.test_method_register..A.tcSs d|_dSNrdrkrrrrr$sz4TestSingleDispatch.test_method_register..A._cSs d|_dSNrkrkrrrrr$sN rrrrsingledispatchmethodr]r'rdr$rkrrrrrs   rrrdrlrirkrc)r]r<rlrr)r!rr+rirrrtest_method_registers    z'TestSingleDispatch.test_method_registercCsJGddd}|}||d||d||dddS)Nc@sJeZdZejeddZeeeddZ ee eddZ dS)z8TestSingleDispatch.test_staticmethod_register..AcSs|Sr rrkrrrr] sz:TestSingleDispatch.test_staticmethod_register..A.tcSs t|tSr )rxrdrkrrrr$ sz:TestSingleDispatch.test_staticmethod_register..A._cSs t|tSr )rxrkrkrrrr$ sN) rrrrrrr]r'rdr$rkrrrrr s  rrrir)r:r]r<r!rr+rrrtest_staticmethod_register s  z-TestSingleDispatch.test_staticmethod_registercCsNGddd}||djd||djd||djddS) Nc@sReZdZddZejeddZee eddZ ee eddZ dS) z7TestSingleDispatch.test_classmethod_register..AcSs ||_dSr rkrrrrr sz@TestSingleDispatch.test_classmethod_register..A.__init__cSs|dSr"rrrlrrrr] sz9TestSingleDispatch.test_classmethod_register..A.tcSs|dSrrrrrrr$" sz9TestSingleDispatch.test_classmethod_register..A._cSs|dSrrrrrrr$& sN) rrrrrrrr]r'rdr$rkrrrrr s  rrrdrirkrrc)r<r]rlrmrrrtest_classmethod_register sz,TestSingleDispatch.test_classmethod_registercCs~Gddd}|jttdd}|jttdd}||djd||djd ||d jd dS) Nc@s&eZdZddZejeddZdS)z4TestSingleDispatch.test_callable_register..AcSs ||_dSr rkrrrrr1 sz=TestSingleDispatch.test_callable_register..A.__init__cSs|dSr"rrrrrr]4 sz6TestSingleDispatch.test_callable_register..A.tN)rrrrrrrr]rrrrr0 srcSs|dSrrrrrrr$9 sz4TestSingleDispatch.test_callable_register.._cSs|dSrrrrrrr$= srrdrirkrrc)r]r'rdrrkr<rl)r!rr$rrrtest_callable_register/ s    z)TestSingleDispatch.test_callable_registercCs$Gdddtj}||jjdS)Nc@s eZdZejejddZdS)zATestSingleDispatch.test_abstractmethod_register..AbstractcSsdSr rrrrrrI szETestSingleDispatch.test_abstractmethod_register..Abstract.addN)rrrrrrrrrrrrrG sr)rrr:rr)r!rrrrtest_abstractmethod_registerF sz/TestSingleDispatch.test_abstractmethod_registercCsNGddd}|}||dd||dd||dddS) Nc@sBeZdZejddZejedddZeje dddZdS)z4TestSingleDispatch.test_type_ann_register..AcSsdSr"rrrrrr]R sz6TestSingleDispatch.test_type_ann_register..A.trkcSsdSrrrrrrr$U sz6TestSingleDispatch.test_type_ann_register..A._cSsdSrrrrrrr$X sNrrrrrrQ s  rrrdrirkrrc)r<r]rrrrtest_type_ann_registerP s  z)TestSingleDispatch.test_type_ann_registercCs`d}d}tjdd}|t"}|ddd}Wdn1sH0Y|t|j|d|t|j ||t}|jd d}Wdn1s0Y|t|j|d |t|j ||t*}|jt j td d d}Wdn1s&0Y|t|jd |t|j ddS)Nz(Invalid first argument to `register()`: zS. Use either `@register(some_class)` or plain `@register` on an annotated function.cSsdSr"rrkrrrr*g sz8TestSingleDispatch.test_invalid_registrations..ir/cSsdS)NzI annotated with a non-typerrkrrrr$k sz8TestSingleDispatch.test_invalid_registrations.._Z42cSsdS)NzI forgot to annotaterrkrrrr$q szB._rkcSsdS)Nz%I annotated with a generic collectionrrkrrrr$z szInvalid annotation for 'arg'.z$typing.Iterable[str] is not a class.) rr&rDrEr'r:rkrrendswithtypingr@)r!Z msg_prefixZ msg_suffixr*excr$rrrtest_invalid_registrationsa s4  ( ( 6z-TestSingleDispatch.test_invalid_registrationscCsHtjdd}d}|t||Wdn1s:0YdS)NcWsdSr rrrrrr^ sz>TestSingleDispatch.test_invalid_positional_argument..fz)f requires at least 1 positional argument)rr&assertRaisesRegexrE)r!r^msgrrr test_invalid_positional_argument s  z3TestSingleDispatch.test_invalid_positional_argumentN)rrrr)r.r0r1r skipUnlessr rZ cpython_onlyr6rJr^rbrjr|rrrrrrrrrrrrrrr!s.   6^f 'r!c@s&eZdZdZddZejddZdS)CachedCostItemr&cCst|_dSr )rRLocklockrGrrrr szCachedCostItem.__init__cCs:|j|jd7_Wdn1s*0Y|jSr)r_costrGrrrcost s,zCachedCostItem.costN)rrrrrrcached_propertyrrrrrr src@s"eZdZdZddZeeZdS)OptionallyCachedCostItemr&cCs|jd7_|jSrrrGrrrget_cost sz!OptionallyCachedCostItem.get_costN)rrrrrrr cached_costrrrrr src@s"eZdZddZejddZdS)CachedCostItemWaitcCsd|_t|_||_dSr)rrrrevent)r!rrrrr s zCachedCostItemWait.__init__cCsF|jd|j|jd7_Wdn1s60Y|jSr)rrrrrGrrrr s ,zCachedCostItemWait.costN)rrrrrrrrrrrr src@s&eZdZdZddZejddZdS)CachedCostItemWithSlotsrcCs d|_dSrrrGrrrr sz CachedCostItemWithSlots.__init__cCs tddS)Nz!never called, slots not supportedr1rGrrrr szCachedCostItemWithSlots.costN)rrr __slots__rrrrrrrrr src@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)TestCachedPropertycCs&t}||jd||jddSr)rr<rr!itemrrr test_cached szTestCachedProperty.test_cachedcCsFt}||d||jd||d||jddS)Nr'r-r.)rr<rrrrrr1test_cached_attribute_name_differs_from_func_name s zDTestCachedProperty.test_cached_attribute_name_differs_from_func_namec st}t|d}t}tdzVfddt|D}t|| Wdn1sf0YWt|n t|0| j ddS)Nr-rcs g|]}tjfdddqS)csjSr )rrrrrr7 r8z=TestCachedProperty.test_threaded...rrrrrrr sz4TestCachedProperty.test_threaded..r') rrrr rrrlrrrr<r)r!ZgoZ num_threadsrrrrr test_threaded s   (z TestCachedProperty.test_threadedcCs<t}|td|jWdn1s.0YdS)NzWNo '__dict__' attribute on 'CachedCostItemWithSlots' instance to cache 'cost' property.)rrrErrrrrtest_object_with_slots s z)TestCachedProperty.test_object_with_slotscCsXGdddt}Gddd|d}|td|jWdn1sJ0YdS)Nc@seZdZejddZdS)z6TestCachedProperty.test_immutable_dict..MyMetacSsdS)NTrrGrrrprop sz;TestCachedProperty.test_immutable_dict..MyMeta.propN)rrrrrrrrrrMyMeta src@s eZdZdS)z7TestCachedProperty.test_immutable_dict..MyClassNrrrrrMyClass srrdzkThe '__dict__' attribute on 'MyMeta' instance does not support item assignment for caching 'prop' property.)rrrEr)r!rrrrrtest_immutable_dict sz&TestCachedProperty.test_immutable_dictcCsX|t}Gddd}Wdn1s.0Y|t|jjttddS)Nc@seZdZejddZeZdS)zKTestCachedProperty.test_reuse_different_names..ReusedCachedPropertycSsdSr rrGrrrr+ szMTestCachedProperty.test_reuse_different_names..ReusedCachedProperty.aN)rrrrrr+r,rrrrReusedCachedProperty s rzLCannot assign the same cached_property to two different names ('a' and 'b').)rDr2r<rkrrrE)r!ctxrrrrtest_reuse_different_names s  ,  z-TestCachedProperty.test_reuse_different_namescstdtjfddGfddd}Gfddd}|}|}||jd||jd ||jddS) Nrcs d7Srr)Z_self)counterrr_cp sz4TestCachedProperty.test_reuse_same_name.._cpcseZdZZdS)z2TestCachedProperty.test_reuse_same_name..ANrrrcprrrrr srcseZdZZdS)z2TestCachedProperty.test_reuse_same_name..BNrrrrrr srr&r')rrr<r)r!rrr+r,r)rrrtest_reuse_same_name sz'TestCachedProperty.test_reuse_same_namecCsZtdd}Gddd}||_|td|jWdn1sL0YdS)NcSsdSr r)rrrrr7# r8z=TestCachedProperty.test_set_name_not_called..c@s eZdZdS)z8TestCachedProperty.test_set_name_not_called..FooNrrrrrFoo$ srzGCannot use cached_property instance without calling __set_name__ on it.)rrrrrE)r!rrrrrtest_set_name_not_called" sz+TestCachedProperty.test_set_name_not_calledcCs|tjtjdSr )ZassertIsInstancerrrrrGrrrtest_access_from_class/ sz)TestCachedProperty.test_access_from_classcCs|tjjddS)NzThe cost of the item.)r<rrrrGrrrtest_doc2 szTestCachedProperty.test_docN) rrrrrrrrrrrrrrrrrr s r__main__)Lrrr`collections.abcr itertoolsrrrandomrr rrrrrrZ unittest.mockosrrr contextlibZtest.support.script_helperrrZimport_fresh_modulerrr contextmanagerrrrrrrr=r$r%rZTestCaserrr9rrrrrrr"r&rBrCrDrdrerfrlrrrrrrrr r!rrrrrrmainrrrrs      F 3  r>O S L   6  r