
    ;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 )BaseClass.getterr   r   s    r   spamzBaseClass.spam        zr   c                     || _         d S Nr   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                  )SubClass.getter)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   r5   r   r   r
   r   r   r2   r2   7   s8        E    0@AAADDDr   r2   c                   H    e Zd Zej        d         Zej        d             ZdS )PropertyDocSubr   c                     | j         S )z*The decorator does not use this doc stringr   r   s    r   r   zPropertyDocSub.spam?   r    r   N)r   r   r	   r2   r/   r   r0   r
   r   r   r9   r9   =   s<        #F+D	[  [  r   r9   c                   H    e Zd Zej        d         Zej        d             ZdS )PropertySubNewGetterr   c                     dS )new docstringr   r
   r   s    r   r   zPropertySubNewGetter.spamF   	     qr   N)r   r   r	   r   r/   r   r0   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 )zoriginal docstringr3   r
   r   s    r   r   zPropertyNewGetter.spamL   r?   r   c                     dS )r>      r
   r   s    r   r   zPropertyNewGetter.spamP   r?   r   N)r   r   r	   r   r   r0   r
   r   r   rA   rA   K   sK           
[  [  r   rA   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abstractmethodrH   r
   r   r   rF   rF   U   s<             r   rF   )	metaclassc                   >    e Zd Zej        ed                         ZdS ) ClassWithPropertyAbstractVirtualc                      d S r"   r
   r
   r   r   rH   z&ClassWithPropertyAbstractVirtual.color\   rI   r   N)r   r   r	   rJ   rK   r   rH   r
   r   r   rN   rN   [   s<             r   rN   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   rV   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   r+   )r)   rU   	__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   r   )r   rU   rf   r/   rg   rY   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   r6   )r2   r9   rU   rf   r/   rg   )r   rZ   ra   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   r>   rD   )r<   rU   r   rf   r/   rg   rA   )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 )NTFr3    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	   rw   __isabstractmethod__r   )vals   r   Cru      s6          +.(++C00r   r|   rw   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 )ru   c                     d S r"   r
   r   s    r   rw   zIPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C.foo   rx   r   Nry   )r   s   r   r|   zEPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C   s<          +2799(++C00r   )objectassertIsr/   rz   boolr]   r   )r   r|   r   r{   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   rH   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   rH   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   rH   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]   	TypeErrorrF   rN   AttributeErrorrH   rU   )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	   r[   rb   unittestskipIfsysflagsoptimizerh   rj   rl   rp   r   r   r
   r   r   rQ   rQ   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   rQ   c                       e Zd ZdZdS )PropertySubz+This is a subclass of DynamicClassAttributeN)r   r   r	   rg   r
   r   r   r   r      s        5555r   r   c                       e Zd ZdZdZdS )PropertySubSlotszBThis is a subclass of DynamicClassAttribute that defines __slots__r
   N)r   r   r	   rg   	__slots__r
   r   r   r   r      s        L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 )
PropertySubclassTestsrg   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 )z5Trying to copy this docstring will raise an exceptionr3   r
   r   s    r   r   zKPropertySubclassTests.test_slots_docstring_copy_exception.<locals>.Foo.spam   s	     1r   
N)r   r   r	   r   r   printrg   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rc   rd   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 ).spam wrapped in DynamicClassAttribute subclassr3   r
   r   s    r   r   z;PropertySubclassTests.test_docstring_copy.<locals>.Foo.spam   	     qr   Nr   r   r	   r   r   r
   r   r   r   r      -          [  r   r   r   r   r   rU   r/   rg   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 )Nr3   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     z!r   c                     || _         dS )zthis docstring is ignoredNr   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   r3   rc   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 )zanother ignored docstringeggsNr   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   rU   r   r/   rg   )r   rw   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 za docstringr3   r
   r   s    r   r   zNPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo.spam  r   r   c                     dS a new docstringrc   r
   r   s    r   r   zNPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo.spam  r   r   N)r   r   r	   r   r   r0   r
   r   r   r   r     sJ          [ [  [  r   r   r   r   c                   $    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   r0   )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   rX   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__)rJ   r   r   typesr   r   r   r   r   r   r   r   r)   r2   r9   r<   rA   ABCMetarF   rN   TestCaserQ   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   