
    ;eC&                     D   d dl Z d dlZd dlZd dlmZ  G d de          Z G d de          Z G d de          Z G d	 d
e          Z	 G d de
          Z G d de          Z G d de
          Z G d de          Z G d de          Z G d de
          Z G d de j                  Z G d de j                  Z G d dej                  Z G d de          Z G d  d!e          Z G d" d#ej                  Zed$k    r ej                     dS dS )%    N)DynamicClassAttributec                       e Zd ZdS )PropertyBaseN__name__
__module____qualname__     6/usr/lib/python3.11/test/test_dynamicclassattribute.pyr   r   	           Dr   r   c                       e Zd ZdS )PropertyGetNr   r
   r   r   r   r      r   r   r   c                       e Zd ZdS )PropertySetNr   r
   r   r   r   r      r   r   r   c                       e Zd ZdS )PropertyDelNr   r
   r   r   r   r      r   r   r   c                   j    e Zd Zd Zed             Zej        d             Zej        d             ZdS )	BaseClassc                     d| _         d S N   _spamselfs    r   __init__zBaseClass.__init__   s    


r   c                     	 | j         S Nr   r   s    r   spamzBaseClass.spam   s    zr   c                     || _         d S r   r   r   values     r   r    zBaseClass.spam   s    


r   c                 
    | ` d S r   r   r   s    r   r    zBaseClass.spam"   s    JJJr   N)r   r   r	   r   r   r    setterdeleterr
   r   r   r   r      sy              
[  [ 
\  \  r   r   c                       e Zd Zej        d         Zej        d             Zej        d             Zej        d             ZdS )SubClassr    c                 ,    	 t          | j                  r   )r   r   r   s    r   r    zSubClass.spam*   s    $*%%%r   c                 *    t          | j                  r   )r   r   r"   s     r   r    zSubClass.spam/       $*%%%r   c                 *    t          | j                  r   )r   r   r   s    r   r    zSubClass.spam3   r+   r   N)	r   r   r	   r   __dict__r    getterr%   r&   r
   r   r   r(   r(   &   sv        f%D	[& & [& 
[& & [& 
\& & \& & &r   r(   c                   2    e Zd ZdZd Z eed          ZdS )PropertyDocBase   c                     | j         S r   r   r   s    r   	_get_spamzPropertyDocBase._get_spam9   s
    zr   spam spam spam)docN)r   r   r	   r   r3   r   r    r
   r   r   r0   r0   7   s8        E    0@AAADDDr   r0   c                   H    e Zd Zej        d         Zej        d             ZdS )PropertyDocSubr    c                     	 | j         S r   r   r   s    r   r    zPropertyDocSub.spam?   s    8zr   N)r   r   r	   r0   r-   r    r.   r
   r   r   r7   r7   =   s<        #F+D	[  [  r   r7   c                   H    e Zd Zej        d         Zej        d             ZdS )PropertySubNewGetterr    c                     	 dS r   r
   r   s    r   r    zPropertySubNewGetter.spamF   
    qr   N)r   r   r	   r   r-   r    r.   r
   r   r   r:   r:   D   s<        f%D	[  [  r   r:   c                   D    e Zd Zed             Zej        d             ZdS )PropertyNewGetterc                     	 dS Nr1   r
   r   s    r   r    zPropertyNewGetter.spamL   s
     qr   c                     	 dS )N   r
   r   s    r   r    zPropertyNewGetter.spamP   r<   r   N)r   r   r	   r   r    r.   r
   r   r   r>   r>   K   sK           
[  [  r   r>   c                   >    e Zd Zeej        d                         ZdS ) ClassWithAbstractVirtualPropertyc                      d S r   r
   r
   r   r   colorz&ClassWithAbstractVirtualProperty.colorV   	     	r   N)r   r   r	   r   abcabstractmethodrF   r
   r   r   rD   rD   U   s<             r   rD   )	metaclassc                   >    e Zd Zej        ed                         ZdS ) ClassWithPropertyAbstractVirtualc                      d S r   r
   r
   r   r   rF   z&ClassWithPropertyAbstractVirtual.color\   rG   r   N)r   r   r	   rH   rI   r   rF   r
   r   r   rL   rL   [   s<             r   rL   c                      e Zd Zd Zd Z ej        ej        j	        dk    d          d             Z
 ej        ej        j	        dk    d          d             Zd Z ej        ej        j	        dk    d          d             Zd	 Zd
 ZdS )PropertyTestsc                 2   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   delattr
assertTruehasattrr   bases     r   !test_property_decorator_baseclassz/PropertyTests.test_property_decorator_baseclassb   s    {{A&&&Q'''	B'''R(((fGD&111222GD'222333	B'''R(((((r   c                     t                      }|                     t          t          |d           |                     t          t
          |dd            |                     t          t          |d           d S )Nr    )r(   assertRaisesr   getattrr   setattrr   rT   r   subs     r    test_property_decorator_subclassz.PropertyTests.test_property_decorator_subclassq   sa    jj+wV<<<+wVTBBB+wV<<<<<r      )Docstrings are omitted with -O2 and abovec                 x    t                      }|                     |j        j        d         j        d           d S )Nr    zSubClass.getter)r(   rS   	__class__r-   __doc__r^   s     r   $test_property_decorator_subclass_docz2PropertyTests.test_property_decorator_subclass_docx   s7     jj/7?ARSSSSSr   c                 x    t                      }|                     |j        j        d         j        d           d S )Nr    zBaseClass.getter)r   rS   rd   r-   re   rW   s     r   %test_property_decorator_baseclass_docz3PropertyTests.test_property_decorator_baseclass_doc~   s7     {{08@BTUUUUUr   c                     t                      }t                      }|                     |j        j        d         j        d           |                     |j        j        d         j        d           d S )Nr    r4   )r0   r7   rS   rd   r-   re   )r   rX   r_   s      r   test_property_decorator_docz)PropertyTests.test_property_decorator_doc   sf      08@BRSSS/7?AQRRRRRr   c                 V   t                      }|                     |j        d           |                     |j        j        d         j        d           t                      }|                     |j        d           |                     |j        j        d         j        d           d S )Nr   r    znew docstringrB   )r:   rS   r    rd   r-   re   r>   )r   newgettersub	newgetters      r   !test_property_getter_doc_overridez/PropertyTests.test_property_getter_doc_override   s     ,--*A.../8@H/ZZZ%''	+++,5f=EWWWWWr   c                 h   ddg dgddfD ]J G fddt                     }|                     |j        d         j        t	                               K G d	 d
t                     |                     t                    5   G fddt                     }d d d            d S # 1 swxY w Y   d S )NTFr1    1c                   :    e Zd Zd Z e_         ee          ZdS )EPropertyTests.test_property___isabstractmethod__descriptor.<locals>.Cc                     d S r   r
   r   s    r   foozIPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C.foo       Dr   Nr   r   r	   ru   __isabstractmethod__r   )vals   r   Crs      s6          +.(++C00r   rz   ru   c                       e Zd Zd ZeZdS )KPropertyTests.test_property___isabstractmethod__descriptor.<locals>.NotBoolc                     t                      r   )
ValueErrorr   s    r   __bool__zTPropertyTests.test_property___isabstractmethod__descriptor.<locals>.NotBool.__bool__   s     ll"r   N)r   r   r	   r   __len__r
   r   r   NotBoolr|      s"        # # #GGGr   r   c                   J    e Zd Zd Z              e_         ee          ZdS )rs   c                     d S r   r
   r   s    r   ru   zIPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C.foo   rv   r   Nrw   )r   s   r   rz   zEPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C   s<          +2799(++C00r   )objectassertIsr-   rx   boolr[   r~   )r   rz   r   ry   s     @@r   ,test_property___isabstractmethod__descriptorz:PropertyTests.test_property___isabstractmethod__descriptor   sY   %aS"c2 	M 	MC1 1 1 1 1 1 1F 1 1 1
 MM!*U+@$s))LLLL	 	 	 	 	f 	 	 	 z** 	1 	11 1 1 1 1 1 1F 1 1 1	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   B''B+.B+c                    |                      t          t                     |                      t          t                      G d dt                    }|                      t          |            G d dt                    }|                      t          |            G d dt                    }|                      t                    5  |j         d d d            n# 1 swxY w Y   |                      |            j        d            G d d	t                    }|                      t                    5  |j         d d d            n# 1 swxY w Y   |                      |            j        d
           d S )Nc                       e Zd ZdS )0PropertyTests.test_abstract_virtual.<locals>.APVNr   r
   r   r   APVr              Dr   r   c                       e Zd ZdS )0PropertyTests.test_abstract_virtual.<locals>.AVPNr   r
   r   r   AVPr      r   r   r   c                   *    e Zd Zed             Zd ZdS )2PropertyTests.test_abstract_virtual.<locals>.Okay1c                     | j         S r   _colorr   s    r   rF   z8PropertyTests.test_abstract_virtual.<locals>.Okay1.color   
    {"r   c                     d| _         d S )Ncyanr   r   s    r   r   z;PropertyTests.test_abstract_virtual.<locals>.Okay1.__init__   s    $r   Nr   r   r	   r   rF   r   r
   r   r   Okay1r      s=        "# # #"#% % % % %r   r   r   c                   *    e Zd Zed             Zd ZdS )2PropertyTests.test_abstract_virtual.<locals>.Okay2c                     | j         S r   r   r   s    r   rF   z8PropertyTests.test_abstract_virtual.<locals>.Okay2.color   r   r   c                     d| _         d S )Nmagentar   r   s    r   r   z;PropertyTests.test_abstract_virtual.<locals>.Okay2.__init__   s    'r   Nr   r
   r   r   Okay2r      s=        "# # #"#( ( ( ( (r   r   r   )r[   	TypeErrorrD   rL   AttributeErrorrF   rS   )r   r   r   r   r   s        r   test_abstract_virtualz#PropertyTests.test_abstract_virtual   s.   )%EFFF)%EFFF	 	 	 	 	2 	 	 	)S)))	 	 	 	 	2 	 	 	)S)))	% 	% 	% 	% 	%4 	% 	% 	% ~.. 	 	KK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	///	( 	( 	( 	( 	(4 	( 	( 	( ~.. 	 	KK	 	 	 	 	 	 	 	 	 	 	 	 	 	 		22222s$   
CC"%C"9EEEN)r   r   r	   rY   r`   unittestskipIfsysflagsoptimizerf   rh   rj   rn   r   r   r
   r   r   rO   rO   a   s(       ) ) )= = = X_SY'1,@B BT TB BT X_SY'1,@B BV VB BVS S S X_SY'1,@B BX XB BX1 1 1,3 3 3 3 3r   rO   c                       e Zd ZdS )PropertySubNr   r
   r   r   r   r      s        55r   r   c                       e Zd Z	 dZdS )PropertySubSlotsr
   N)r   r   r	   	__slots__r
   r   r   r   r      s        LIIIr   r   c                   F   e Zd Z ej         eed          d          d             Z ej        ej	        j
        dk    d          d             Z ej        ej	        j
        dk    d          d             Z ej        ej	        j
        dk    d          d             Zd	S )
PropertySubclassTestsre   z9__doc__ is already present, __slots__ will have no effectc                 j    	  G d dt                     }t          d          # t          $ r Y d S w xY w)Nc                   F    e Zd Zed             Z edej                   dS )FPropertySubclassTests.test_slots_docstring_copy_exception.<locals>.Fooc                     	 dS r@   r
   r   s    r   r    zKPropertySubclassTests.test_slots_docstring_copy_exception.<locals>.Foo.spam   s
    O1r   
N)r   r   r	   r   r    printre   r
   r   r   Foor      s@        !  "! d4<(((((r   r   zAttributeError not raised)r   	Exceptionr   r   r   s     r   #test_slots_docstring_copy_exceptionz9PropertySubclassTests.test_slots_docstring_copy_exception   sf    
	9) ) ) ) )f ) ) ) 7888  	 	 	DD	s   $ 
22ra   rb   c                 x     G d dt                     }|                     |j        d         j        d           d S )Nc                   $    e Zd Zed             ZdS )6PropertySubclassTests.test_docstring_copy.<locals>.Fooc                     	 dS r@   r
   r   s    r   r    z;PropertySubclassTests.test_docstring_copy.<locals>.Foo.spam   s
    Dqr   Nr   r   r	   r   r    r
   r   r   r   r      -          [  r   r   r    .spam wrapped in DynamicClassAttribute subclassr   rS   r-   re   r   s     r   test_docstring_copyz)PropertySubclassTests.test_docstring_copy   s`    	 	 	 	 	& 	 	 	
 	L (<	> 	> 	> 	> 	>r   c                     G d dt                                  }|                     |j        d           d|_        |                     |j        d           |                     j        d         j        d            G fdd          } |            }|                     |j        d           d	|_        |                     |j        d
           |                     |j        d         j        d           d S )Nc                   J    e Zd Zd Zed             Zej        d             ZdS )OPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.Fooc                     d| _         d S r@   r   r   s    r   r   zXPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.Foo.__init__   s    Q


r   c                     	 | j         S r   r   r   s    r   r    zTPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.Foo.spam   s    Dz!r   c                     	 || _         d S r   r   r"   s     r   r    zTPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.Foo.spam   s    /"


r   N)r   r   r	   r   r   r    r%   r
   r   r   r   r      sS        ..." " [" [# # [# # #r   r   r1   ra   r    r   c                   J    e Zd Z j        d         Zej        d             ZdS )RPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.FooSubr    c                     	 d| _         d S )Neggsr   r"   s     r   r    zWPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.FooSub.spam  s    /#


r   N)r   r   r	   r-   r    r%   )r   s   r   FooSubr      s<        <'D[$ $ [$ $ $r   r      r   )r   rS   r    r-   re   )r   ru   r   foosubr   s       @r   ,test_property_setter_copies_getter_docstringzBPropertySubclassTests.test_property_setter_copies_getter_docstring   sC   		# 		# 		# 		# 		#& 		# 		# 		# cee1%%%1%%%L (<	> 	> 	>	$ 	$ 	$ 	$ 	$ 	$ 	$S 	$ 	$ 	$ a(((f---OF#+<	> 	> 	> 	> 	>r   c                     G d dt                     }|                     |j        d         j        d            G d dt                      G fdd          }|                     |j        d         j        d           d S )	Nc                   D    e Zd Zed             Zej        d             ZdS )IPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Fooc                     	 dS r@   r
   r   s    r   r    zNPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo.spam  
    !qr   c                     	 dS Nra   r
   r   s    r   r    zNPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo.spam  
    %qr   N)r   r   r	   r   r    r.   r
   r   r   r   r     sJ          [ [  [  r   r   r    za new docstringc                   $    e Zd Zed             ZdS )MPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.FooBasec                     	 dS r@   r
   r   s    r   r    zRPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.FooBase.spam  r   r   Nr   r
   r   r   FooBaser     r   r   r   c                   J    e Zd Z j        d         Zej        d             ZdS )JPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo2r    c                     	 dS r   r
   r   s    r   r    zOPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo2.spam#  r   r   N)r   r   r	   r-   r    r.   )r   s   r   Foo2r   !  s=        #F+D[  [  r   r   r   )r   r   r   r   s      @r   &test_property_new_getter_new_docstringz<PropertySubclassTests.test_property_new_getter_new_docstring  s    	 	 	 	 	& 	 	 	 	f-57HIII	 	 	 	 	f 	 	 	
	 	 	 	 	 	 	7 	 	 	 	f-57HIIIIIr   N)r   r   r	   r   r   rV   r   r   r   r   r   r   r   r   r
   r   r   r   r      s       X_WW-y99GI I9 9I I9 X_SY'1,@B B> >B B> X_SY'1,@B B> >B B>@ X_SY'1,@B BJ JB BJ J Jr   r   __main__)rH   r   r   typesr   r   r   r   r   r   r   r   r(   r0   r7   r:   r>   ABCMetarD   rL   TestCaserO   r   r   r   r   mainr
   r   r   <module>r      s2   


 



  ' ' ' ' ' '	 	 	 	 	9 	 	 		 	 	 	 	, 	 	 		 	 	 	 	, 	 	 		 	 	 	 	, 	 	 	       "& & & & &y & & &"B B B B Bf B B B    _       9                          c3 c3 c3 c3 c3H% c3 c3 c3N6 6 6 6 6' 6 6 6    ,   XJ XJ XJ XJ XJH- XJ XJ XJx zHMOOOOO r   