
    <e-                     V   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          Z G d de          Z G d dej                  Z G d d           Z G d! d"eej                  Z G d# d$eej                  Zed%k    r ej                     dS dS )&    N)supportc                       e Zd ZdS )PropertyBaseN__name__
__module____qualname__     )/usr/lib/python3.11/test/test_property.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   propertyr    setterdeleterr
   r   r   r   r      sx             X 
[  [ 
\  \  r   r   c                   x    e Zd Zej        j        d             Zej        d             Zej        d             ZdS )SubClassc                 ,    	 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.spam0   r,   r   N)r   r   r	   r   r    getterr&   r'   r
   r   r   r)   r)   %   sm        ^& & & 
[& & [& 
\& & \& & &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_spam6   s
    zr   spam spam spamdocN)r   r   r	   r   r3   r%   r    r
   r   r   r0   r0   4   s7        E  8I#3444DDDr   r0   c                   8    e Zd Zej        j        d             ZdS )PropertyDocSubc                     	 | 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   r8   r8   :   s4           !   r   r8   c                   8    e Zd Zej        j        d             ZdS )PropertySubNewGetterc                     	 dS r   r
   r   s    r   r    zPropertySubNewGetter.spamA   
    qr   N)r   r   r	   r   r    r.   r
   r   r   r;   r;   @   s3        ^    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.spamG   s
     qr   c                     	 dS )N   r
   r   s    r   r    zPropertyNewGetter.spamK   r=   r   N)r   r   r	   r%   r    r.   r
   r   r   r?   r?   F   sJ          X 
[  [  r   r?   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 ej        ej        j	        dk    d          d
             Z ej        ej        j	        dk    d          d             Zej        d             Z ej        ej        j	        dk    d          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_baseclassQ   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   rJ   r   subs     r    test_property_decorator_subclassz.PropertyTests.test_property_decorator_subclass`   sa    jj+wV<<<+wVTBBB+wV<<<<<r      )Docstrings are omitted with -O2 and abovec                 l    t                      }|                     |j        j        j        d           d S )NzSubClass.getter)r)   rI   	__class__r    __doc__rT   s     r   $test_property_decorator_subclass_docz2PropertyTests.test_property_decorator_subclass_docg   s2     jj+35FGGGGGr   c                 l    t                      }|                     |j        j        j        d           d S )NzBaseClass.getter)r   rI   rZ   r    r[   rM   s     r   %test_property_decorator_baseclass_docz3PropertyTests.test_property_decorator_baseclass_docm   s2     {{,46HIIIIIr   c                     t                      }t                      }|                     |j        j        j        d           |                     |j        j        j        d           d S )Nr4   )r0   r8   rI   rZ   r    r[   )r   rN   rU   s      r   test_property_decorator_docz)PropertyTests.test_property_decorator_docs   s\      ,46FGGG+35EFFFFFr   c                 >   t                      }|                     |j        d           |                     |j        j        j        d           t                      }|                     |j        d           |                     |j        j        j        d           d S )Nr   znew docstringrC   )r;   rI   r    rZ   r[   r?   )r   newgettersub	newgetters      r   !test_property_getter_doc_overridez/PropertyTests.test_property_getter_doc_overridey   s     ,--*A.../4<oNNN%''	+++,19?KKKKKr   c                 t   ddg dgddfD ]D G fddt                     }|                     |j        j        t	                               E G d d	t                     |                     t                    5   G fd
dt                     }|j        j         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	   rk   __isabstractmethod__r%   )vals   r   Cri      s3          +.(hsmmr   rp   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	   ru   __len__r
   r   r   NotBoolrr      s"        # # #GGGr   rw   c                   J    e Zd Zd Z              e_         ee          ZdS )ri   c                     d S r   r
   r   s    r   rk   zIPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C.foo   rl   r   Nrm   )rw   s   r   rp   zEPropertyTests.test_property___isabstractmethod__descriptor.<locals>.C   s9          +2799(hsmmr   )objectassertIsrk   rn   boolrQ   rt   )r   rp   rw   ro   s     @@r   ,test_property___isabstractmethod__descriptorz:PropertyTests.test_property___isabstractmethod__descriptor   sa   %aS"c2 	A 	AC$ $ $ $ $ $ $F $ $ $
 MM!%4d3ii@@@@	 	 	 	 	f 	 	 	 z** 	' 	'$ $ $ $ $ $ $F $ $ $
 E&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   >"B--B14B1c                     t          d          }|                     |j        d           d|_        |                     |j        d           d S )Nbasicr5   extended)r%   rI   r[   )r   ps     r   "test_property_builtin_doc_writablez0PropertyTests.test_property_builtin_doc_writable   sQ     !!!G,,,	J/////r   c                      G d dt                     } |            }|                     |j        j        j        d           d|j        j        _        |                     |j        j        j        d           d S )Nc                   $    e Zd Zed             ZdS )OPropertyTests.test_property_decorator_doc_writable.<locals>.PropertyWritableDocc                     	 dS Neggsr
   r   s    r   r    zTPropertyTests.test_property_decorator_doc_writable.<locals>.PropertyWritableDoc.spam   s
    vr   N)r   r   r	   r%   r    r
   r   r   PropertyWritableDocr      s-          X  r   r   EggsSpam)rz   rI   rZ   r    r[   )r   r   rU   s      r   $test_property_decorator_doc_writablez2PropertyTests.test_property_decorator_doc_writable   s    	 	 	 	 	& 	 	 	 "!##+3V<<<%+"+3V<<<<<r   c                    t          j        t          d          }t          dddd          } |            }t	          d          D ]}|                    dddd           |                      |            |z
  dd	           d S )
Ngettotalrefcountfgetfsetfdelr6   d   r   rG   )delta)r   get_attributesysr%   ranger   assertAlmostEqual)r   r   	fake_proprefs_beforeis        r   test_refleaks_in___init__z'PropertyTests.test_refleaks_in___init__   s    "06HIIVVVU;;	&&((s 	> 	>Avvvu====//11K?"MMMMMr   c                 V     G d d          }|                      |j        d           d S )Nc                   4    e Zd Zeed                         ZdS ),PropertyTests.test_class_property.<locals>.Ac                     d| j         z  S )NzA doc for %r)r   clss    r   r[   z4PropertyTests.test_class_property.<locals>.A.__doc__   s     &44r   Nr   r   r	   classmethodr%   r[   r
   r   r   Ar      s7        5 5 X [5 5 5r   r   zA doc for 'A'rI   r[   r   r   s     r   test_class_propertyz!PropertyTests.test_class_property   sJ    	5 	5 	5 	5 	5 	5 	5 	5
 	O44444r   c                 V     G d d          }|                      |j        d           d S )Nc                   6    e Zd Z	 eed                         ZdS )5PropertyTests.test_class_property_override.<locals>.Ac                     dS )NSecondr
   r   s    r   r[   z=PropertyTests.test_class_property_override.<locals>.A.__doc__   s	      xr   Nr   r
   r   r   r   r      s:            X [     r   r   r   r   r   s     r   test_class_property_overridez*PropertyTests.test_class_property_override   sJ    	  	  	  	  	  	  	  	  	H-----r   c                     t                      }dD ]G}|                     t          d| d          5   |j        dg|z    d d d            n# 1 swxY w Y   Hd S )N)r   r1      z3^__set_name__\(\) takes 2 positional arguments but z were given$r   )r%   assertRaisesRegex	TypeError__set_name__)r   r   r   s      r   %test_property_set_name_incorrect_argsz3PropertyTests.test_property_set_name_incorrect_args   s    JJ 	+ 	+A''VqVVV  + + !q**	+ + + + + + + + + + + + + + +	+ 	+s   AA	A	c                      G d dt                     } G d d          }t                               |          }|                    |d           |                    d           }d S )Nc                       e Zd Zd ZdS )EPropertyTests.test_property_setname_on_property_subclass.<locals>.proc                     dS )Nabcdefr
   )typargskwargss      r   __new__zMPropertyTests.test_property_setname_on_property_subclass.<locals>.pro.__new__   s    xr   N)r   r   r	   r   r
   r   r   pror      s#                 r   r   c                       e Zd ZdS )CPropertyTests.test_property_setname_on_property_subclass.<locals>.ANr   r
   r   r   r   r      s        Dr   r   r1   c                     dS rA   r
   r   s    r   <lambda>zJPropertyTests.test_property_setname_on_property_subclass.<locals>.<lambda>   s    1 r   )r%   r   r   r.   )r   r   r   r   nps        r   *test_property_setname_on_property_subclassz8PropertyTests.test_property_setname_on_property_subclass   s    	  	  	  	  	 ( 	  	  	 	 	 	 	 	 	 	 	 S!!	q!XXnn%%r   N)r   r   r	   rO   rV   unittestskipIfr   flagsoptimizer\   r^   r`   rd   r}   r   r   r   refcount_testr   r   r   r   r   r
   r   r   rE   rE   P   sU       ) ) )= = = X_SY'1,@B BH HB BH X_SY'1,@B BJ JB BJG G G X_SY'1,@B BL LB BL' ' '. X_SY'1,@B B0 0B B0 X_SY'1,@B B= =B B= N N N X_SY'1,@B B5 5B B5 X_SY'1,@B B. .B B.+ + +& & & & &r   rE   c                       e Zd ZdS )PropertySubNr   r
   r   r   r   r      s        ((r   r   c                       e Zd Z	 dZdS )PropertySubSlotsr
   N)r   r   r	   	__slots__r
   r   r   r   r      s        ?IIIr   r   c                      e 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
 ej        ej        j        dk    d          d             ZdS )PropertySubclassTestsc                 j    	  G d dt                     }t          d          # t          $ r Y d S w xY w)Nc                   $    e Zd Zed             ZdS )FPropertySubclassTests.test_slots_docstring_copy_exception.<locals>.Fooc                     	 dS rA   r
   r   s    r   r    zKPropertySubclassTests.test_slots_docstring_copy_exception.<locals>.Foo.spam   s
    O1r   N)r   r   r	   r   r    r
   r   r   Foor      s.        !  "!  r   r   zAttributeError not raised)rz   	ExceptionAttributeError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rW   rX   c                 l     G d dt                     }|                     |j        j        d           d S )Nc                   $    e Zd Zed             ZdS )6PropertySubclassTests.test_docstring_copy.<locals>.Fooc                     	 dS rA   r
   r   s    r   r    z;PropertySubclassTests.test_docstring_copy.<locals>.Foo.spam  s
    7qr   Nr   r   r	   r   r    r
   r   r   r   r     -          [  r   r   !spam wrapped in property subclassrz   rI   r    r[   r   s     r   test_docstring_copyz)PropertySubclassTests.test_docstring_copy  s[    	 	 	 	 	& 	 	 	
 	H/	1 	1 	1 	1 	1r   c                     G d dt                                  }|                     |j        d           d|_        |                     |j        d           |                     j        j        d            G fdd          } |            }|                     |j        d           d|_        |                     |j        d	           |                     |j        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 rA   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    7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   rW   r   c                   :    e Zd Z j        j        d             ZdS )RPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.FooSubc                     	 d| _         d S r   r   r"   s     r   r    zWPropertySubclassTests.test_property_setter_copies_getter_docstring.<locals>.FooSub.spam"  s    /#


r   N)r   r   r	   r    r&   )r   s   r   FooSubr   !  s2        X_$ $ _$ $ $r   r      r   r   )r   rk   r   foosubr   s       @r   ,test_property_setter_copies_getter_docstringzBPropertySubclassTests.test_property_setter_copies_getter_docstring  s9   		# 		# 		# 		# 		#& 		# 		# 		# cee1%%%1%%%H/	1 	1 	1	$ 	$ 	$ 	$ 	$ 	$ 	$S 	$ 	$ 	$
 a(((f---K/	1 	1 	1 	1 	1r   c                      G d dt                     }|                     |j        j        d            G d dt                      G fdd          }|                     |j        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 rA   r
   r   s    r   r    zNPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo.spam3  
    !qr   c                     	 dS NrW   r
   r   s    r   r    zNPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo.spam7  
    %qr   N)r   r   r	   r   r    r.   r
   r   r   r   r   2  sJ          [ [  [  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 rA   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                   :    e Zd Z j        j        d             ZdS )JPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo2c                     	 dS r   r
   r   s    r   r    zOPropertySubclassTests.test_property_new_getter_new_docstring.<locals>.Foo2.spamB  r   r   N)r   r   r	   r    r.   )r   s   r   Foo2r   A  s4        \   !   r   r   r   )r   r   r   r   s      @r   &test_property_new_getter_new_docstringz<PropertySubclassTests.test_property_new_getter_new_docstring.  s    	 	 	 	 	& 	 	 	 	)+<===	 	 	 	 	f 	 	 	
	 	 	 	 	 	 	7 	 	 	
 	)+<=====r   N)r   r   r	   r   r   r   r   r   r   r   r   r   r
   r   r   r   r      s        
9 
9 
9 X_SY'1,@B B1 1B B1 X_SY'1,@B B1 1B B1> X_SY'1,@B B> >B B> > >r   r   c                   H    e Zd ZdZdZdZd Zed             Zd Z	d Z
d ZdS )_PropertyUnreachableAttributeNc                 6    | j                             |          S r   )
msg_formatformat)r   msgs     r   _format_exc_msgz-_PropertyUnreachableAttribute._format_exc_msgN  s    %%c***r   c                 8    |                                  | _        d S r   )r   objr   s    r   
setUpClassz(_PropertyUnreachableAttribute.setUpClassQ  s    ''))r   c                     |                      t          |                     d                    5  | j        j         d d d            d S # 1 swxY w Y   d S )Nzhas no getterr   r   r  r  rk   r   s    r   test_get_propertyz/_PropertyUnreachableAttribute.test_get_propertyU  s    ##ND4H4H4Y4YZZ 	 	HLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   A		AAc                     |                      t          |                     d                    5  d | j        _        d d d            d S # 1 swxY w Y   d S )Nzhas no setterr  r   s    r   test_set_propertyz/_PropertyUnreachableAttribute.test_set_propertyY  s    ##ND4H4H4Y4YZZ 	  	 DHL	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 r  c                     |                      t          |                     d                    5  | j        `d d d            d S # 1 swxY w Y   d S )Nzhas no deleterr  r   s    r   test_del_propertyz/_PropertyUnreachableAttribute.test_del_property]  s    ##ND4H4HIY4Z4Z[[ 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAA)r   r   r	   r  r  r   r  r   r	  r  r  r  r
   r   r   r  r  I  sz        J
C
C+ + +   [           r   r  c                   ,    e Zd ZdZ G d d          ZdS )$PropertyUnreachableAttributeWithNamezI^property 'foo' of 'PropertyUnreachableAttributeWithName\.cls' object {}$c                   "    e Zd Z e            ZdS )(PropertyUnreachableAttributeWithName.clsN)r   r   r	   r%   rk   r
   r   r   r   r  e  s        hjjr   r   N)r   r   r	   r  r   r
   r   r   r  r  b  sA        ]J         r   r  c                   J    e Zd ZdZ G d d          Z e            e_        dS )"PropertyUnreachableAttributeNoNamezA^property of 'PropertyUnreachableAttributeNoName\.cls' object {}$c                       e Zd ZdS )&PropertyUnreachableAttributeNoName.clsNr   r
   r   r   r   r  l  s        r   r   N)r   r   r	   r  r   r%   rk   r
   r   r   r  r  i  sJ        UJ        hjjCGGGr   r  __main__)r   r   testr   r   r   r   r   r   rz   r   r)   r0   r8   r;   r?   TestCaserE   r%   r   r   r   r  r  r  r   mainr
   r   r   <module>r     s=   


       	 	 	 	 	9 	 	 		 	 	 	 	, 	 	 		 	 	 	 	, 	 	 		 	 	 	 	, 	 	 	       "& & & & &y & & &5 5 5 5 5f 5 5 5    _       9          Y& Y& Y& Y& Y&H% Y& Y& Y&x) ) ) ) )( ) ) )    x   S> S> S> S> S>H- S> S> S>l       2    +H(J[       )FHY    zHMOOOOO r   