a zeC&@sFddlZddlZddlZddlmZGdddeZGdddeZGdddeZGd d d eZ Gd d d e Z Gd dde Z Gddde Z Gddde ZGddde ZGddde ZGdddejdZGdddejdZGdddejZGdddeZGd d!d!eZGd"d#d#ejZed$krBedS)%N)DynamicClassAttributec@s eZdZdS) PropertyBaseN__name__ __module__ __qualname__rrS/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_dynamicclassattribute.pyr src@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)rrrrrrsetterdeleterrrrr r s  r c@s@eZdZejdZejddZejddZejddZdS)SubClassrcCst|jdS)SubClass.getterN)r rrrrr r*sz SubClass.spamcCst|jdSr)r rrrrr r/scCst|jdSr)r rrrrr r3sN) rrrr __dict__rgetterrrrrrr r&s   rc@s$eZdZdZddZeeddZdS)PropertyDocBasecCs|jSrrrrrr _get_spam9szPropertyDocBase._get_spamspam spam spam)docN)rrrrr!rrrrrr r7src@s$eZdZejdZejddZdS)PropertyDocSubrcCs|jS)z*The decorator does not use this doc stringrrrrr r?szPropertyDocSub.spamN)rrrrrrrrrrr r$=s r$c@s$eZdZejdZejddZdS)PropertySubNewGetterrcCsdS) new docstringrrrrrr rFszPropertySubNewGetter.spamN)rrrr rrrrrrr r%Ds r%c@s&eZdZeddZejddZdS)PropertyNewGettercCsdS)zoriginal docstringr rrrrr rLszPropertyNewGetter.spamcCsdS)r&rrrrr rPsN)rrrrrrrrrr r'Ks r'c@seZdZeejddZdS) ClassWithAbstractVirtualPropertycCsdSrrrrrr colorVsz&ClassWithAbstractVirtualProperty.colorN)rrrrabcabstractmethodr*rrrr r)Usr)) metaclassc@seZdZejeddZdS) ClassWithPropertyAbstractVirtualcCsdSrrrrrr r*\sz&ClassWithPropertyAbstractVirtual.colorN)rrrr+r,rr*rrrr r.[sr.c@seZdZddZddZeejj dkdddZ eejj dkdd d Z d d Z eejj dkdd dZ ddZddZdS) PropertyTestscCst}||jd||jdd|_||jd||jdt|d|t|d |t|d d|_||jd||jddS)Nr rr)r assertEqualrrdelattrZ assertTruehasattrrbaserrr !test_property_decorator_baseclassbs z/PropertyTests.test_property_decorator_baseclasscCs<t}|tt|d|tt|dd|tt|ddS)Nr)r assertRaisesr getattrr setattrr r3rsubrrr test_property_decorator_subclassqsz.PropertyTests.test_property_decorator_subclass)Docstrings are omitted with -O2 and abovecCs t}||jjdjddS)Nrr)rr2 __class__r__doc__r;rrr $test_property_decorator_subclass_docxsz2PropertyTests.test_property_decorator_subclass_doccCs t}||jjdjddS)Nrr)r r2r@rrAr5rrr %test_property_decorator_baseclass_doc~sz3PropertyTests.test_property_decorator_baseclass_doccCs<t}t}||jjdjd||jjdjddS)Nrr")rr$r2r@rrA)rr6r<rrr test_property_decorator_docsz)PropertyTests.test_property_decorator_doccCsXt}||jd||jjdjdt}||jd||jjdjddS)Nrrr&r()r%r2rr@rrAr')rZ newgettersubZ newgetterrrr !test_property_getter_doc_overrides z/PropertyTests.test_property_getter_doc_overridecsddgdgddfD]0Gfdddt}||jdjtqGd d d t|t$Gfd ddt}Wdn1s0YdS) NTFr 1cs"eZdZddZe_eeZdS)EPropertyTests.test_property___isabstractmethod__descriptor..CcSsdSrrrrrr foosIPropertyTests.test_property___isabstractmethod__descriptor..C.fooNrrrrI__isabstractmethod__rr)valrr CsrNrIc@seZdZddZeZdS)zKPropertyTests.test_property___isabstractmethod__descriptor..NotBoolcSs tdSr) ValueErrorrrrr __bool__szTPropertyTests.test_property___isabstractmethod__descriptor..NotBool.__bool__N)rrrrP__len__rrrr NotBoolsrRcs$eZdZddZe_eeZdS)rHcSsdSrrrrrr rIsrJNrKr)rRrr rNs)objectZassertIsrrLboolr8rO)rrNr)rRrMr ,test_property___isabstractmethod__descriptors  z:PropertyTests.test_property___isabstractmethod__descriptorcCs|tt|ttGdddt}|t|Gdddt}|t|Gdddt}|t|jWdn1s0Y||jdGdd d t}|t|jWdn1s0Y||jd dS) Nc@s eZdZdS)z0PropertyTests.test_abstract_virtual..APVNrrrrr APVsrVc@s eZdZdS)z0PropertyTests.test_abstract_virtual..AVPNrrrrr AVPsrWc@s eZdZeddZddZdS)z2PropertyTests.test_abstract_virtual..Okay1cSs|jSrZ_colorrrrr r*sz8PropertyTests.test_abstract_virtual..Okay1.colorcSs d|_dS)NcyanrXrrrr rsz;PropertyTests.test_abstract_virtual..Okay1.__init__Nrrrrr*rrrrr Okay1s r[rYc@s eZdZeddZddZdS)z2PropertyTests.test_abstract_virtual..Okay2cSs|jSrrXrrrr r*sz8PropertyTests.test_abstract_virtual..Okay2.colorcSs d|_dS)NmagentarXrrrr rsz;PropertyTests.test_abstract_virtual..Okay2.__init__NrZrrrr Okay2s r]r\)r8 TypeErrorr)r.AttributeErrorr*r2)rrVrWr[r]rrr test_abstract_virtuals     $ $z#PropertyTests.test_abstract_virtualN)rrrr7r=unittestskipIfsysflagsoptimizerBrCrDrErUr`rrrr r/as"   r/c@seZdZdZdS) PropertySubz+This is a subclass of DynamicClassAttributeN)rrrrArrrr rfsrfc@seZdZdZdZdS)PropertySubSlotszBThis is a subclass of DynamicClassAttribute that defines __slots__rN)rrrrA __slots__rrrr rgsrgc@szeZdZeeeddddZeej j dkdddZ eej j dkdd d Z eej j dkdd d Z d S)PropertySubclassTestsrAz9__doc__ is already present, __slots__ will have no effectcCs4zGdddt}Wnty&Yn 0tddS)Nc@s$eZdZeddZedejdS)zFPropertySubclassTests.test_slots_docstring_copy_exception..FoocSsdS)z5Trying to copy this docstring will raise an exceptionr rrrrr rszKPropertySubclassTests.test_slots_docstring_copy_exception..Foo.spam N)rrrrgrprintrArrrr Foos rlzAttributeError not raised)rSr_ Exceptionrrlrrr #test_slots_docstring_copy_exceptions  z9PropertySubclassTests.test_slots_docstring_copy_exceptionr>r?cCs(Gdddt}||jdjddS)Nc@seZdZeddZdS)z6PropertySubclassTests.test_docstring_copy..FoocSsdS).spam wrapped in DynamicClassAttribute subclassr rrrrr rsz;PropertySubclassTests.test_docstring_copy..Foo.spamNrrrrfrrrrr rlsrlrrprSr2rrArnrrr test_docstring_copys  z)PropertySubclassTests.test_docstring_copycsGdddt}||jdd|_||jd|jdjdGfddd}|}||jdd |_||jd ||jdjddS) 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)rprrrrr rszTPropertySubclassTests.test_property_setter_copies_getter_docstring..Foo.spamcSs ||_dS)zthis docstring is ignoredNrrrrr rsN)rrrrrfrrrrrr rls  rlr r>rrpcs$eZdZjdZejddZdS)zRPropertySubclassTests.test_property_setter_copies_getter_docstring..FooSubrcSs d|_dS)zanother ignored docstringeggsNrrrrr rszWPropertySubclassTests.test_property_setter_copies_getter_docstring..FooSub.spamN)rrrrrrrrlrr FooSubs rwru)rSr2rrrA)rrIrwZfoosubrrvr ,test_property_setter_copies_getter_docstrings$   zBPropertySubclassTests.test_property_setter_copies_getter_docstringcs`Gdddt}||jdjdGdddtGfddd}||jdjddS) Nc@s&eZdZeddZejddZdS)zIPropertySubclassTests.test_property_new_getter_new_docstring..FoocSsdSz a docstringr rrrrr rszNPropertySubclassTests.test_property_new_getter_new_docstring..Foo.spamcSsdSa new docstringr>rrrrr rsN)rrrrfrrrrrr rls rlrr|c@seZdZeddZdS)zMPropertySubclassTests.test_property_new_getter_new_docstring..FooBasecSsdSrzrrrrr rszRPropertySubclassTests.test_property_new_getter_new_docstring..FooBase.spamNrqrrrr FooBasesr}cs$eZdZjdZejddZdS)zJPropertySubclassTests.test_property_new_getter_new_docstring..Foo2rcSsdSr{rrrrr r#szOPropertySubclassTests.test_property_new_getter_new_docstring..Foo2.spamN)rrrrrrrr}rr Foo2!s rrr)rrlrrr~r &test_property_new_getter_new_docstrings  zs*  g\