o
    HXhC&                     @   sH  d dl Z d dlZd dlZd dlmZ G dd deZG dd deZG dd deZG d	d
 d
eZ	G dd de
ZG dd deZG dd de
ZG dd deZG dd deZG dd de
ZG dd de jdZG dd de jdZG dd dejZG dd deZG d d! d!eZG d"d# d#ejZed$kre  dS dS )%    N)DynamicClassAttributec                   @      e Zd ZdS )PropertyBaseN__name__
__module____qualname__ r	   r	   I/opt/python-3.10.19/usr/lib/python3.10/test/test_dynamicclassattribute.pyr   	       r   c                   @   r   )PropertyGetNr   r	   r	   r	   r
   r      r   r   c                   @   r   )PropertySetNr   r	   r	   r	   r
   r      r   r   c                   @   r   )PropertyDelNr   r	   r	   r	   r
   r      r   r   c                   @   s<   e Zd Zdd Zedd Zejdd Zejdd ZdS )	BaseClassc                 C   
   d| _ d S N   _spamselfr	   r	   r
   __init__      
zBaseClass.__init__c                 C      	 | j S Nr   r   r	   r	   r
   spam      zBaseClass.spamc                 C   s
   || _ d S r   r   r   valuer	   r	   r
   r         
c                 C   s   | ` d S r   r   r   r	   r	   r
   r   "   s   N)r   r   r   r   r   r   setterdeleterr	   r	   r	   r
   r      s    

r   c                   @   s@   e Zd Zejd Zejdd Zejdd Zejdd ZdS )SubClassr   c                 C   s   	 t | jr   )r   r   r   r	   r	   r
   r   *      
zSubClass.spamc                 C   
   t | jr   )r   r   r   r	   r	   r
   r   /   r   c                 C   r$   r   )r   r   r   r	   r	   r
   r   3   r   N)	r   r   r   r   __dict__r   getterr    r!   r	   r	   r	   r
   r"   &   s    


r"   c                   @   s$   e Zd ZdZdd ZeeddZdS )PropertyDocBase   c                 C      | j S r   r   r   r	   r	   r
   	_get_spam9      zPropertyDocBase._get_spamspam spam spam)docN)r   r   r   r   r*   r   r   r	   r	   r	   r
   r'   7   s    r'   c                   @   $   e Zd Zejd Zejdd ZdS )PropertyDocSubr   c                 C   r   r   r   r   r	   r	   r
   r   ?   r   zPropertyDocSub.spamN)r   r   r   r'   r%   r   r&   r	   r	   r	   r
   r/   =       
r/   c                   @   r.   )PropertySubNewGetterr   c                 C      	 dS r   r	   r   r	   r	   r
   r   F      zPropertySubNewGetter.spamN)r   r   r   r   r%   r   r&   r	   r	   r	   r
   r1   D   r0   r1   c                   @   &   e Zd Zedd Zejdd ZdS )PropertyNewGetterc                 C   r2   Nr(   r	   r   r	   r	   r
   r   L   r3   zPropertyNewGetter.spamc                 C   r2   )N   r	   r   r	   r	   r
   r   P   r3   N)r   r   r   r   r   r&   r	   r	   r	   r
   r5   K   
    
r5   c                   @   s   e Zd Zeejdd ZdS ) ClassWithAbstractVirtualPropertyc                   C      d S r   r	   r	   r	   r	   r
   colorV      z&ClassWithAbstractVirtualProperty.colorN)r   r   r   r   abcabstractmethodr;   r	   r	   r	   r
   r9   U   s    r9   )	metaclassc                   @   s   e Zd Zejedd ZdS ) ClassWithPropertyAbstractVirtualc                   C   r:   r   r	   r	   r	   r	   r
   r;   \   r<   z&ClassWithPropertyAbstractVirtual.colorN)r   r   r   r=   r>   r   r;   r	   r	   r	   r
   r@   [   s    r@   c                   @   s   e Zd Zdd Zdd Zeejj	dkddd Z
eejj	dkdd	d
 Zdd Zeejj	dkddd Zdd Zdd ZdS )PropertyTestsc                 C   s   t  }| |jd | |jd d|_| |jd | |jd t|d | t|d  | t|d  d|_| |jd | |jd d S )Nr   
   r   r      )r   assertEqualr   r   delattrZ
assertTruehasattrr   baser	   r	   r
   !test_property_decorator_baseclassb   s   
z/PropertyTests.test_property_decorator_baseclassc                 C   s<   t  }| tt|d | tt|dd  | tt|d d S )Nr   )r"   assertRaisesr   getattrr   setattrr   rE   r   subr	   r	   r
    test_property_decorator_subclassq   s   z.PropertyTests.test_property_decorator_subclass   )Docstrings are omitted with -O2 and abovec                 C       t  }| |jjd jd d S )Nr   zSubClass.getter)r"   rD   	__class__r%   __doc__rM   r	   r	   r
   $test_property_decorator_subclass_docx      z2PropertyTests.test_property_decorator_subclass_docc                 C   rR   )Nr   zBaseClass.getter)r   rD   rS   r%   rT   rG   r	   r	   r
   %test_property_decorator_baseclass_doc~   rV   z3PropertyTests.test_property_decorator_baseclass_docc                 C   s<   t  }t }| |jjd jd | |jjd jd d S )Nr   r,   )r'   r/   rD   rS   r%   rT   )r   rH   rN   r	   r	   r
   test_property_decorator_doc   s   z)PropertyTests.test_property_decorator_docc                 C   sX   t  }| |jd | |jjd jd t }| |jd | |jjd jd d S )Nr   r   znew docstringr7   )r1   rD   r   rS   r%   rT   r5   )r   ZnewgettersubZ	newgetterr	   r	   r
   !test_property_getter_doc_override   s   z/PropertyTests.test_property_getter_doc_overridec                    s   ddg dgddfD ]G fdddt }| |jd jt q	G d	d
 d
t  | t G  fdddt }W d    d S 1 sEw   Y  d S )NTFr(    1c                       s"   e Zd Zdd Z e_eeZdS )EPropertyTests.test_property___isabstractmethod__descriptor.<locals>.Cc                 S   r:   r   r	   r   r	   r	   r
   foo      IPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C.fooNr   r   r   r]   __isabstractmethod__r   r	   )valr	   r
   C   s    rc   r]   c                   @   s   e Zd Zdd ZeZdS )zKPropertyTests.test_property___isabstractmethod__descriptor.<locals>.NotBoolc                 S   s   t  r   )
ValueErrorr   r	   r	   r
   __bool__   r+   zTPropertyTests.test_property___isabstractmethod__descriptor.<locals>.NotBool.__bool__N)r   r   r   re   __len__r	   r	   r	   r
   NotBool   s    rg   c                       s$   e Zd Zdd Z  e_eeZdS )r\   c                 S   r:   r   r	   r   r	   r	   r
   r]      r^   r_   Nr`   r	   )rg   r	   r
   rc      s    )objectZassertIsr%   ra   boolrJ   rd   )r   rc   r	   )rg   rb   r
   ,test_property___isabstractmethod__descriptor   s   "z:PropertyTests.test_property___isabstractmethod__descriptorc                 C   s   |  tt |  tt G dd dt}|  t| G dd dt}|  t| G dd dt}|  t |j W d    n1 sCw   Y  | | jd G dd	 d	t}|  t |j W d    n1 skw   Y  | | jd
 d S )Nc                   @   r   )z0PropertyTests.test_abstract_virtual.<locals>.APVNr   r	   r	   r	   r
   APV   r   rk   c                   @   r   )z0PropertyTests.test_abstract_virtual.<locals>.AVPNr   r	   r	   r	   r
   AVP   r   rl   c                   @       e Zd Zedd Zdd ZdS )z2PropertyTests.test_abstract_virtual.<locals>.Okay1c                 S   r)   r   Z_colorr   r	   r	   r
   r;         z8PropertyTests.test_abstract_virtual.<locals>.Okay1.colorc                 S   r   )Ncyanrn   r   r	   r	   r
   r      r   z;PropertyTests.test_abstract_virtual.<locals>.Okay1.__init__Nr   r   r   r   r;   r   r	   r	   r	   r
   Okay1       
rr   rp   c                   @   rm   )z2PropertyTests.test_abstract_virtual.<locals>.Okay2c                 S   r)   r   rn   r   r	   r	   r
   r;      ro   z8PropertyTests.test_abstract_virtual.<locals>.Okay2.colorc                 S   r   )Nmagentarn   r   r	   r	   r
   r      r   z;PropertyTests.test_abstract_virtual.<locals>.Okay2.__init__Nrq   r	   r	   r	   r
   Okay2   rs   ru   rt   )rJ   	TypeErrorr9   r@   AttributeErrorr;   rD   )r   rk   rl   rr   ru   r	   r	   r
   test_abstract_virtual   s    z#PropertyTests.test_abstract_virtualN)r   r   r   rI   rO   unittestskipIfsysflagsoptimizerU   rW   rX   rY   rj   rx   r	   r	   r	   r
   rA   a   s$    


rA   c                   @   r   )PropertySubNr   r	   r	   r	   r
   r~      r   r~   c                   @   s   e Zd Z	 dZdS )PropertySubSlotsr	   N)r   r   r   	__slots__r	   r	   r	   r
   r      s    r   c                   @   sz   e Zd Zeeedddd Zeej	j
dkddd Zeej	j
dkdd	d
 Zeej	j
dkddd ZdS )PropertySubclassTestsrT   z9__doc__ is already present, __slots__ will have no effectc                 C   s0   zG dd dt }W td ty   Y d S w )Nc                   @   s$   e Zd Zedd Zedej dS )zFPropertySubclassTests.test_slots_docstring_copy_exception.<locals>.Fooc                 S   r2   r6   r	   r   r	   r	   r
   r      r3   zKPropertySubclassTests.test_slots_docstring_copy_exception.<locals>.Foo.spam
N)r   r   r   r   r   printrT   r	   r	   r	   r
   Foo   s    
r   zAttributeError not raised)rh   rw   	Exceptionr   r   r	   r	   r
   #test_slots_docstring_copy_exception   s   	z9PropertySubclassTests.test_slots_docstring_copy_exceptionrP   rQ   c                 C   s(   G dd dt }| |jd jd d S )Nc                   @      e Zd Zedd ZdS )z6PropertySubclassTests.test_docstring_copy.<locals>.Fooc                 S   r2   r6   r	   r   r	   r	   r
   r      r3   z;PropertySubclassTests.test_docstring_copy.<locals>.Foo.spamNr   r   r   r~   r   r	   r	   r	   r
   r          r   r   .spam wrapped in DynamicClassAttribute subclassrh   rD   r%   rT   r   r	   r	   r
   test_docstring_copy   s
   
z)PropertySubclassTests.test_docstring_copyc                    s   G dd dt    }| |jd d|_| |jd |  jd jd G  fddd }| }| |jd d	|_| |jd
 | |jd jd d S )Nc                   @   s.   e Zd Zdd Zedd Zejdd ZdS )zOPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.Fooc                 S   r   r6   r   r   r	   r	   r
   r      s   
 zXPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.Foo.__init__c                 S   r   r   r   r   r	   r	   r
   r      r   zTPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.Foo.spamc                 S   s   	 || _ d S r   r   r   r	   r	   r
   r      r#   N)r   r   r   r   r~   r   r    r	   r	   r	   r
   r      s    
r   r(   rP   r   r   c                       $   e Zd Z jd Zejdd ZdS )zRPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.FooSubr   c                 S   s   	 d| _ d S )Neggsr   r   r	   r	   r
   r     r#   zWPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.FooSub.spamN)r   r   r   r%   r   r    r	   r   r	   r
   FooSub   r0   r      r   )rh   rD   r   r%   rT   )r   r]   r   Zfoosubr	   r   r
   ,test_property_setter_copies_getter_docstring   s$   


zBPropertySubclassTests.test_property_setter_copies_getter_docstringc                    s`   G dd dt }| |jd jd G dd dt  G  fddd }| |jd jd d S )	Nc                   @   r4   )zIPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Fooc                 S   r2   r6   r	   r   r	   r	   r
   r     r3   zNPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo.spamc                 S   r2   NrP   r	   r   r	   r	   r
   r     r3   N)r   r   r   r~   r   r&   r	   r	   r	   r
   r     r8   r   r   za new docstringc                   @   r   )zMPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.FooBasec                 S   r2   r6   r	   r   r	   r	   r
   r     r3   zRPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.FooBase.spamNr   r	   r	   r	   r
   FooBase  r   r   c                       r   )zJPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo2r   c                 S   r2   r   r	   r   r	   r	   r
   r   #  r3   zOPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo2.spamN)r   r   r   r%   r   r&   r	   r   r	   r
   Foo2!  r0   r   r   )r   r   r   r	   r   r
   &test_property_new_getter_new_docstring  s
   	z<PropertySubclassTests.test_property_new_getter_new_docstringN)r   r   r   ry   rz   rF   r   r   r{   r|   r}   r   r   r   r	   r	   r	   r
   r      s"    



 r   __main__)r=   r{   ry   typesr   r   r   r   r   r   rh   r   r"   r'   r/   r1   r5   ABCMetar9   r@   ZTestCaserA   r~   r   r   r   mainr	   r	   r	   r
   <module>   s.   
g\