a ze%@sddlZddlZddlmZGdddeZGdddeZGdddeZGd d d eZGd d d e Z Gd dde Z Gddde Z Gddde Z Gddde ZGddde ZGdddejZGdddeZGdddeZGdddejZedkredS) N)supportc@s eZdZdS) PropertyBaseN__name__ __module__ __qualname__rrF/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_property.pyrsrc@s eZdZdS) PropertyGetNrrrrr r sr c@s eZdZdS) PropertySetNrrrrr r sr c@s eZdZdS) PropertyDelNrrrrr r sr c@s<eZdZddZeddZejddZejddZdS) BaseClasscCs d|_dS)N_spamselfrrr __init__szBaseClass.__init__cCs|jS)BaseClass.getterrrrrr spamszBaseClass.spamcCs ||_dSNrrvaluerrr rscCs|`dSrrrrrr r!sN)rrrrpropertyrsetterdeleterrrrr r s  r c@s8eZdZejjddZejddZejddZdS)SubClasscCst|jdS)SubClass.getterN)r rrrrr r'sz SubClass.spamcCst|jdSr)r rrrrr r,scCst|jdSr)r rrrrr r0sN)rrrr rgetterrrrrrr r%s   rc@s$eZdZdZddZeeddZdS)PropertyDocBasecCs|jSrrrrrr _get_spam6szPropertyDocBase._get_spamspam spam spamdocN)rrrrr!rrrrrr r4src@seZdZejjddZdS)PropertyDocSubcCs|jS)z*The decorator does not use this doc stringrrrrr r;szPropertyDocSub.spamN)rrrrrrrrrr r%:sr%c@seZdZejjddZdS)PropertySubNewGettercCsdS) new docstringrrrrrr rAszPropertySubNewGetter.spamN)rrrr rrrrrr r&@sr&c@s&eZdZeddZejddZdS)PropertyNewGettercCsdS)zoriginal docstringr rrrrr rGszPropertyNewGetter.spamcCsdS)r'rrrrr rKsN)rrrrrrrrrr r(Fs r(c@seZdZddZddZeejj dkdddZ eejj dkdd d Z d d Z eejj dkdd dZ ddZeejj dkdddZeejj dkdddZejddZeejj dkdddZeejj dkdddZdS) PropertyTestscCst}||jd||jdd|_||jd||jdt|d|t|d |t|d d|_||jd||jddS)Nr rr)r assertEqualrrdelattrZ assertTruehasattrrbaserrr !test_property_decorator_baseclassQs z/PropertyTests.test_property_decorator_baseclasscCs<t}|tt|d|tt|dd|tt|ddS)Nr)r assertRaisesr getattrr setattrr r.rsubrrr test_property_decorator_subclass`sz.PropertyTests.test_property_decorator_subclass)Docstrings are omitted with -O2 and abovecCst}||jjjddS)Nr)rr- __class__r__doc__r6rrr $test_property_decorator_subclass_docgsz2PropertyTests.test_property_decorator_subclass_doccCst}||jjjddS)Nr)r r-r;rr<r0rrr %test_property_decorator_baseclass_docmsz3PropertyTests.test_property_decorator_baseclass_doccCs4t}t}||jjjd||jjjddS)Nr")rr%r-r;rr<)rr1r7rrr test_property_decorator_docssz)PropertyTests.test_property_decorator_doccCsPt}||jd||jjjdt}||jd||jjjddS)Nrr'r))r&r-rr;r<r()rZ newgettersubZ newgetterrrr !test_property_getter_doc_overrideys z/PropertyTests.test_property_getter_doc_overridecsddgdgddfD],Gfdddt}||jjtqGdd d t|t,Gfd ddt}|jjWdn1s0YdS) NTFr 1cs"eZdZddZe_eeZdS)EPropertyTests.test_property___isabstractmethod__descriptor..CcSsdSrrrrrr foosIPropertyTests.test_property___isabstractmethod__descriptor..C.fooNrrrrD__isabstractmethod__rr)valrr CsrIc@seZdZddZeZdS)zKPropertyTests.test_property___isabstractmethod__descriptor..NotBoolcSs tdSr) ValueErrorrrrr __bool__szTPropertyTests.test_property___isabstractmethod__descriptor..NotBool.__bool__N)rrrrK__len__rrrr NotBoolsrMcs$eZdZddZe_eeZdS)rCcSsdSrrrrrr rDsrENrFr)rMrr rIs)objectZassertIsrDrGboolr3rJ)rrIr)rMrHr ,test_property___isabstractmethod__descriptors z:PropertyTests.test_property___isabstractmethod__descriptorcCs0tdd}||jdd|_||jddS)NZbasicr#Zextended)rr-r<)rprrr "test_property_builtin_doc_writables z0PropertyTests.test_property_builtin_doc_writablecCsHGdddt}|}||jjjdd|jj_||jjjddS)Nc@seZdZeddZdS)zOPropertyTests.test_property_decorator_doc_writable..PropertyWritableDoccSsdS)Eggseggsrrrrr rszTPropertyTests.test_property_decorator_doc_writable..PropertyWritableDoc.spamN)rrrrrrrrr PropertyWritableDocsrUrSZSpam)rNr-r;rr<)rrUr7rrr $test_property_decorator_doc_writables  z2PropertyTests.test_property_decorator_doc_writablecCsXttd}tdddd}|}tdD]}|ddddq(|j||ddd dS) Ngettotalrefcountfgetfsetfdelr$drr+)Zdelta)rZ get_attributesysrrangerZassertAlmostEqual)rrWZ fake_propZ refs_beforeirrr test_refleaks_in___init__s   z'PropertyTests.test_refleaks_in___init__cCs Gddd}||jddS)Nc@seZdZeeddZdS)z,PropertyTests.test_class_property..AcSs d|jS)Nz A doc for %r)rclsrrr r<sz4PropertyTests.test_class_property..A.__doc__N)rrr classmethodrr<rrrr Asrcz A doc for 'A'r-r<rrcrrr test_class_propertysz!PropertyTests.test_class_propertycCs Gddd}||jddS)Nc@s eZdZdZeeddZdS)z5PropertyTests.test_class_property_override..AZFirstcSsdS)NSecondrr`rrr r<sz=PropertyTests.test_class_property_override..A.__doc__N)rrrr<rbrrrrr rcsrcrgrdrerrr test_class_property_overridesz*PropertyTests.test_class_property_overrideN)rrrr2r8unittestskipIfr\flagsoptimizer=r>r?r@rPrRrVrZ refcount_testr_rfrhrrrr r*PsD       r*c@seZdZdZdS) PropertySubzThis is a subclass of propertyN)rrrr<rrrr rmsrmc@seZdZdZdZdS)PropertySubSlotsz5This is a subclass of property that defines __slots__rN)rrrr< __slots__rrrr rnsrnc@sheZdZddZeejjdkdddZ eejjdkdddZ eejjdkdd d Z d S) PropertySubclassTestscCs4zGdddt}Wnty&Yn 0tddS)Nc@seZdZeddZdS)zFPropertySubclassTests.test_slots_docstring_copy_exception..FoocSsdS)z5Trying to copy this docstring will raise an exceptionr rrrrr rszKPropertySubclassTests.test_slots_docstring_copy_exception..Foo.spamN)rrrrnrrrrr FoosrqzAttributeError not raised)rNAttributeError Exceptionrrqrrr #test_slots_docstring_copy_exceptions  z9PropertySubclassTests.test_slots_docstring_copy_exceptionr9r:cCs$Gdddt}||jjddS)Nc@seZdZeddZdS)z6PropertySubclassTests.test_docstring_copy..FoocSsdS)!spam wrapped in property subclassr rrrrr rsz;PropertySubclassTests.test_docstring_copy..Foo.spamNrrrrmrrrrr rqsrqrvrNr-rr<rtrrr test_docstring_copys z)PropertySubclassTests.test_docstring_copycsGdddt}||jdd|_||jd|jjdGfddd}|}||jdd|_||jd ||jjddS) Nc@s.eZdZddZeddZejddZdS)zOPropertySubclassTests.test_property_setter_copies_getter_docstring..FoocSs d|_dS)Nr rrrrr rzXPropertySubclassTests.test_property_setter_copies_getter_docstring..Foo.__init__cSs|jS)rvrrrrr rszTPropertySubclassTests.test_property_setter_copies_getter_docstring..Foo.spamcSs ||_dS)zthis docstring is ignoredNrrrrr rsN)rrrrrmrrrrrr rqs  rqr r9rvcseZdZjjddZdS)zRPropertySubclassTests.test_property_setter_copies_getter_docstring..FooSubcSs d|_dS)zanother ignored docstringrTNrrrrr rszWPropertySubclassTests.test_property_setter_copies_getter_docstring..FooSub.spamN)rrrrrrrqrr FooSubsr|rTrx)rrDr|Zfoosubrr{r ,test_property_setter_copies_getter_docstrings$ zBPropertySubclassTests.test_property_setter_copies_getter_docstringcsXGdddt}||jjdGdddtGfddd}||jjddS)Nc@s&eZdZeddZejddZdS)zIPropertySubclassTests.test_property_new_getter_new_docstring..FoocSsdSz a docstringr rrrrr rszNPropertySubclassTests.test_property_new_getter_new_docstring..Foo.spamcSsdSa new docstringr9rrrrr rsN)rrrrmrrrrrr rqs rqrc@seZdZeddZdS)zMPropertySubclassTests.test_property_new_getter_new_docstring..FooBasecSsdSrrrrrr r"szRPropertySubclassTests.test_property_new_getter_new_docstring..FooBase.spamNrwrrrr FooBase!srcseZdZjjddZdS)zJPropertySubclassTests.test_property_new_getter_new_docstring..Foo2cSsdSrrrrrr r'szOPropertySubclassTests.test_property_new_getter_new_docstring..Foo2.spamN)rrrrrrrrr Foo2&srrx)rrqrrrr &test_property_new_getter_new_docstrings  zs&  W