Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_funcattrs.cpython-311.opt-2.pyc
�

�Kep;���ddlZddlZddlZd�ZGd�dej��ZGd�de��ZGd�de��ZGd	�d
e��ZGd�de��Z	Gd
�de��Z
d�Zdd�ZGd�dej��Z
Gd�dej��ZGd�dej��Zedkrej��dSdS)�Nc���d���fd�S)Nc�&�Gd�d��}d�a|S)Nc��eZdZdS)�;global_function.<locals>.inner_function.<locals>.LocalClassN)�__name__�
__module__�__qualname__���=/usr/local/apps/python3/lib/python3.11/test/test_funcattrs.py�
LocalClassrs�������Drr
c��d�}|S)Nc��dS�Nr
r
rr�inner_function2z.inner_global_function.<locals>.inner_function2����rr
)rs r�inner_global_functionrs��
�
�
�"�"r)r)r
s r�inner_functionz'global_function.<locals>.inner_functionsA��	�	�	�	�	�	�	�	�	#�	#�	#��rc����Srr
�rs�r�<lambda>z!global_function.<locals>.<lambda>s���>�rr
rs@r�global_functionrs#������"�!�!�!�!rc��eZdZd�Zd�ZdS)�
FuncAttrsTestc�`�Gd�d��}d�}|��|_||_||_dS)Nc��eZdZd�ZdS)�FuncAttrsTest.setUp.<locals>.Fc��dSrr
��selfs r�az FuncAttrsTest.setUp.<locals>.F.arrN)rrr	r!r
rr�Frs#������
�
�
�
�
rr"c��dS�N�r
r
rr�bzFuncAttrsTest.setUp.<locals>.bs���1r)�fir"r&)r r"r&s   r�setUpzFuncAttrsTest.setUpsX��	�	�	�	�	�	�	�	�	�	�	��!�#�#����������rc���	t|||��|�d|�d|����n#|$rYnwxYw	t||��|�d|z��dS#|$rYdSwxYw)Nzshouldn't be able to set z to zshouldn't be able to del %s)�setattr�fail�delattr)r �obj�name�value�
exceptionss     r�cannot_set_attrzFuncAttrsTest.cannot_set_attrs���	K��C��u�%�%�%�
�I�I�I�T�T�T�5�5�I�J�J�J�J���	�	�	��D�	����	<��C�����
�I�I�3�d�:�;�;�;�;�;���	�	�	��D�D�	���s�/�7�7�A%�%A.�-A.N)rrr	r(r1r
rrrrs2���������<�<�<�<�<rrc�h�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�ZdS)�FunctionPropertiesTestc�P�|�|jjt��dSr)�assertEqualr&rrrs r�test_modulez"FunctionPropertiesTest.test_module/s#�������*�H�5�5�5�5�5rc���d|j_|�dt|j��d��d|jj_|�dt|jj��d��dS)N��
known_attrz+set attributes not in dir listing of methodzEset attribute on function implementations, should show up in next dir)r&r9�assertIn�dirr"r!r'rs r�test_dir_includes_correct_attrsz6FunctionPropertiesTest.test_dir_includes_correct_attrs2sx�������
�
�l�C���K�K�9�	;�	;�	;� ������
�
�l�C���	�N�N�5C�	D�	D�	D�	D�	Drc�B�d�}|�|j|��dS)Nc��	dSr$r
r
rr�	duplicatezJFunctionPropertiesTest.test_duplicate_function_equality.<locals>.duplicate=s
����1r)�assertNotEqualr&)r r?s  r� test_duplicate_function_equalityz7FunctionPropertiesTest.test_duplicate_function_equality;s1��	�	�	�	
���D�F�I�.�.�.�.�.rc��d�}|�|��d��|jj|_|�|��d��dS)Nc��dSrr
r
rr�testz:FunctionPropertiesTest.test_copying___code__.<locals>.testC����rr%)r5r&�__code__)r rDs  r�test_copying___code__z,FunctionPropertiesTest.test_copying___code__BsT�������������&�&�&�����
���������#�#�#�#�#rc��|�|jjt����|�|jddt
tf��dS)N�__globals__�)�assertIsr&rI�globalsr1�AttributeError�	TypeErrorrs r�test___globals__z'FunctionPropertiesTest.test___globals__HsQ���
�
�d�f�(�'�)�)�4�4�4����T�V�]�A�,�i�8�	:�	:�	:�	:�	:rc�@�|�|jjt��|�|jddtt
f��d�}i}t
|��|j|��}|�|j|��|�|jt��|�	|d��d��|�	|i��tjd��}ddi}t|d�}t||��|�|d	j|��|�|d
j|��|�|d	jd|��|�
d|d
j��dS)N�__builtins__rJc� �t|��Sr)�len)�ss r�funcz6FunctionPropertiesTest.test___builtins__.<locals>.funcTs��C��F�F�]r�abcr%z\
            def func3(s): pass
            func4 = type(func3)(func3.__code__, {})
        �None)�typerQ�func3�func4)rKr&rQr1rMrNrXrFrIr5�textwrap�dedent�exec�assertNotIn)r rU�ns�func2�code�
safe_builtinss      r�test___builtins__z(FunctionPropertiesTest.test___builtins__Ms����
�
�d�f�)�<�8�8�8����T�V�^�Q�,�i�8�	:�	:�	:�
	#�"�"�
����T�
�
�4�=�"�-�-���
�
�e�'��,�,�,��
�
�e�(�,�7�7�7�	
�����u���q�)�)�)�����R� � � ��� �
�
�� ���
��M�
:�
:���T�2�����
�
�b��k�.�
�>�>�>��
�
�b��k�.�
�>�>�>��
�
�b��k�-�n�=�}�M�M�M������G��)@�A�A�A�A�Arc�&��d��fd�}|j}|�|t��|�t	|��d��|�|djjd��|�|d|t��dS)N�c�&��t���dSr��print�r!s�r�fz2FunctionPropertiesTest.test___closure__.<locals>.fn�����q�����r�r�cell�__closure__)	rn�assertIsInstance�tupler5rS�	__class__rr1rM�r rj�cr!s   @r�test___closure__z'FunctionPropertiesTest.test___closure__ls�����������
�M�����a��'�'�'�����Q����#�#�#�����1���0�&�9�9�9����Q�
�q�.�A�A�A�A�Arc��tjd��}|�|jd��tj��}d}|�t
|���5|jddd��dS#1swxYwYdS)Nrl�'shouldn't be able to read an empty cell)�msg)�types�CellTyper5�
cell_contents�assertRaises�
ValueError)r �cell_objrws   r�
test_cell_newz$FunctionPropertiesTest.test_cell_newvs����>�!�$�$������/��3�3�3��>�#�#��7��
�
�
�z�s�
�
3�
3�	#�	#��"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�	#�	#s�!A6�6A:�=A:c����fd�}	|jdj|�d��n#t$rYnwxYwd�dS)Nc�&��t���dSrrgris�rrjz1FunctionPropertiesTest.test_empty_cell.<locals>.f�rkrrrvre)rnrzr+r|)r rjr!s  @r�test_empty_cellz&FunctionPropertiesTest.test_empty_cellsm��������	A�
�M�!��*�*�
�I�I�?�@�@�@�@���	�	�	��D�	����
���s�0�
=�=c�\��d��fd�}|j}d|d_|�|djd��|�|��d��|��d��|d`	|dj|�d��n#t$rYnwxYw|�t��5|��ddd��n#1swxYwY|�t��5t���ddd��dS#1swxYwYdS)Nrec����Srr
ris�rrjz/FunctionPropertiesTest.test_set_cell.<locals>.f�s����r�	rrv)	rnrzr5r+r|r{�	NameError�UnboundLocalErrorrhrrs   @r�
test_set_cellz$FunctionPropertiesTest.test_set_cell�s�����������
�M����!�������1��+�Q�/�/�/��������a� � � �����A����
�a�D��	A�
�a�D���
�I�I�?�@�@�@�@���	�	�	��D�	�����
�
�y�
)�
)�	�	�
�A�C�C�C�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�0�
1�
1�	�	��!�H�H�H�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s6�;
B�
B+�*B+�C�C#�&C#�D!�!D%�(D%c��|�|jjd��d|j_|�|jjd��d|j_|�|jjd��|�|jddt��d}t|dii��|�|jjjd��|�|jjddt��dS)	Nr&rs�drr8zdef f(): pass
f.__name__rQr!)	r5r&rr1rNr]r'r!rM)r rTs  r�
test___name__z$FunctionPropertiesTest.test___name__�s���������#�.�.�.�����������#�.�.�.�����������#�.�.�.����T�V�Z��I�>�>�>�
,���Q���$�%�%�%�������+�S�1�1�1����T�W�Y�
�C��H�H�H�H�Hrc�l�|�|jjd��|�tjjd��|�t
jd��|�t��jd��|�t����jd��|�t������jd��|�tjd��|�t
��jd��d	|j_|�|jjd	��d
|j_|�|jjd
��|�|jddt��dS)
NzFuncAttrsTest.setUp.<locals>.bzFuncAttrsTest.setUprz!global_function.<locals>.<lambda>z'global_function.<locals>.inner_functionrrz.inner_global_function.<locals>.inner_function2rsr�r	r8)	r5r&r	rr(rrr1rNrs r�test___qualname__z(FunctionPropertiesTest.test___qualname__�s��������,�.N�O�O�O�����,�9�;P�Q�Q�Q�����5�7H�I�I�I�����*�*�7�<�	>�	>�	>����*��*�*�,�,�9�B�	D�	D�	D����,�*��*�*�,�,�.�.�;�V�	X�	X�	X����.�;�=T�U�U�U����.�0�0�=�?o�p�p�p�!���������,�c�2�2�2�!���������,�c�2�2�2����T�V�^�Q�	�B�B�B�B�Brc����d\��d�}d�}�fd�}�fd�}��fd�}|||||fD]4}|�t|j��tj���5|�|��d��|�|��d��|j|_|�|j|j��|�|��d��	|j|_|�d	��n#t$rYnwxYw	|j|_|�d	��dS#t$rYdSwxYw)
N)r8�c��dSrr
r
rrr!z/FunctionPropertiesTest.test___code__.<locals>.a�rErc��dS)Nrer
r
rrr&z/FunctionPropertiesTest.test___code__.<locals>.b�s���rc����Srr
)�num_ones�rrsz/FunctionPropertiesTest.test___code__.<locals>.c������rc����Srr
)�num_twos�rr�z/FunctionPropertiesTest.test___code__.<locals>.d�r�rc�����fSrr
)r�r�s��r�ez/FunctionPropertiesTest.test___code__.<locals>.e�s
�����(�(rr8r�zC__code__ with different numbers of free vars should not be possible)r5rXrFrx�CodeTyper+r|)	r r!r&rsr�r�rUr�r�s	       @@r�
test___code__z$FunctionPropertiesTest.test___code__�s����������
�
��������������(�(�(�(�(�(���1�a��O�	B�	B�D����T�$�-�0�0�%�.�A�A�A�A��������a� � � ��������a� � � ��Z��
������Q�Z�0�0�0��������a� � � �	)���A�J�
�I�I�(�
)�
)�
)�
)���	�	�	��D�	����
	)���A�J�
�I�I�(�
)�
)�
)�
)�
)���	�	�	��D�D�	���s$�!D�
D�D�D7�7
E�Ec��|�|jjd��|j`|�|jjd��dSr)r5r&�__defaults__rs r�test_blank_func_defaultsz/FunctionPropertiesTest.test_blank_func_defaults�sF�������,�d�3�3�3��F�������,�d�3�3�3�3�3rc��d�}dd�}|�|jd��|�|jd��d|_|�|jd��|�|��d��|�|d��d��|�|dd��d��|`|�|jd��	|��|�d	��dS#t$rYdSwxYw)
Nc��||zSrr
�r!r&s  r�
first_funczAFunctionPropertiesTest.test_func_default_args.<locals>.first_func�����Q�3�JrrlrJc��||zSrr
r�s  r�second_funczBFunctionPropertiesTest.test_func_default_args.<locals>.second_func�r�r)rlrJr%�r�zE__defaults__ does not update; deleting it does not remove requirement)r5r�r+rN)r r�r�s   r�test_func_default_argsz-FunctionPropertiesTest.test_func_default_args�sN��	�	�	�	�	�	�	�����0�$�7�7�7�����1�6�:�:�:�"(�
������0�&�9�9�9��������q�)�)�)������A����*�*�*������A�q�)�)�1�-�-�-��$�����1�4�8�8�8�	,��K�M�M�M�
�I�I�+�
,�
,�
,�
,�
,���	�	�	��D�D�	���s�
C<�<
D
�	D
N)rrr	r6r<rArGrOrcrtr~r�r�r�r�r�r�r�r
rrr3r3-s������6�6�6�D�D�D�/�/�/�$�$�$�:�:�:�
B�B�B�>B�B�B�#�#�#�������(I�I�I� C�C�C�()�)�)�<4�4�4�
,�,�,�,�,rr3c�&�eZdZd�Zd�Zd�Zd�ZdS)�InstancemethodAttrTestc��|�|jjjj|j��|�|jjd|jt��dS)Nrq)r5r'r!�__self__rqr"r1rNrs r�test___class__z%InstancemethodAttrTest.test___class__�sJ��������+�5�t�v�>�>�>����T�W�Y��T�V�Y�G�G�G�G�Grc���|�|jjj|jj��|�|jjd|jjt��dS)N�__func__)r5r'r!r�r"r1rMrs r�
test___func__z$InstancemethodAttrTest.test___func__sK��������+�T�V�X�6�6�6����T�W�Y�
�D�F�H�n�M�M�M�M�Mrc��|�|jjj|j��|�|jjd|jt
��dS)Nr�)r5r'r!r�r1rMrs r�
test___self__z$InstancemethodAttrTest.test___self__sG��������+�T�W�5�5�5����T�W�Y�
�D�G�^�L�L�L�L�Lrc��tjt|j��|j_|�|j���t|j����	|jjj|�d��n#t$rYnwxYw|�|jjddt��dS)N�4using unknown attributes should raise AttributeError�unknown_attrrJ)	rx�
MethodType�idr'r5r�r+rMr1rs r�test___func___non_methodz/InstancemethodAttrTest.test___func___non_method	s����%�b�$�'�2�2���
����������r�$�'�{�{�3�3�3�	N��G�J�#�#�
�I�I�L�M�M�M�M���	�	�	��D�	����
	
���T�W�Z���N�K�K�K�K�Ks�*B�
B�BN)rrr	r�r�r�r�r
rrr�r��s^������H�H�H�N�N�N�M�M�M�
L�
L�
L�
L�
Lrr�c� �eZdZd�Zd�Zd�ZdS)�ArbitraryFunctionAttrTestc���d|j_|�|jjd��	d|jj_|�d��dS#t$rYdSwxYw)Nr8z0setting attributes on methods should raise error)r&r9r5r'r!r+rMrs r�
test_set_attrz'ArbitraryFunctionAttrTest.test_set_attrsx�����������*�A�.�.�.�	J�#$�D�G�I� �
�I�I�H�I�I�I�I�I���	�	�	��D�D�	���s�A�
A$�#A$c�b�	|j`|�d��dS#t$rYdSwxYw)Nz1deleting unknown attribute should raise TypeError)r&r�r+rMrs r�test_delete_unknown_attrz2ArbitraryFunctionAttrTest.test_delete_unknown_attr$sO��	K���#�
�I�I�I�J�J�J�J�J���	�	�	��D�D�	����� �
.�.c��|j|jjfD]/}	|j|�d��� #t
$rY�,wxYwdS)Nr�)r&r'r!�non_existent_attrr+rM)r rUs  r�test_unset_attrz)ArbitraryFunctionAttrTest.test_unset_attr,sx���V�T�W�Y�'�	,�	,�D�
,��&�&��	�	�+�,�,�,�,��"�
�
�
���
����	,�	,s�4�
A�AN)rrr	r�r�r�r
rrr�r�sG������J�J�J�K�K�K�,�,�,�,�,rr�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�FunctionDictsTestc���|�|jddt��ddlm}|ddi��}|�|jjjd|t��dS)N�__dict__r)�UserDictr9r8)r1r&rN�collectionsr�r'r!r�)r r�r�s   r�test_setting_dict_to_invalidz.FunctionDictsTest.test_setting_dict_to_invalid8sk�����T�V�Z��y�A�A�A�(�(�(�(�(�(��H�l�A�&�'�'�����T�W�Y�/��Q�	�J�J�J�J�Jrc�P�ddi}||j_|�||jj��||jj_|�||jjjj��|�||jjj��|�|jjd��|�|jjdd��|�|jjjjd��|�|jjjd��dS)Nr9r8)	r&r�rKr"r!r'r�r5r9)r r�s  r�test_setting_dict_to_validz,FunctionDictsTest.test_setting_dict_to_valid>s���
�1��������
�
�a����)�)�)�������
�
�a����+�4�5�5�5��
�
�a����+�,�,�,������*�A�.�.�.��������6��:�:�:�������+�6��:�:�:�������-�q�1�1�1�1�1rc�b�	|j`|�d��dS#t$rYdSwxYw)Nz3deleting function dictionary should raise TypeError)r&r�r+rNrs r�test_delete___dict__z&FunctionDictsTest.test_delete___dict__NsN��	M����
�I�I�K�L�L�L�L�L���	�	�	��D�D�	���r�c�F�|�|jji��dSr)r5r&r�rs r�test_unassigned_dictz&FunctionDictsTest.test_unassigned_dictVs"��������"�-�-�-�-�-rc�d�d}i}|||j<|�||j|��dS)NzSome string)r&r5)r r/r�s   r�test_func_as_dict_keyz'FunctionDictsTest.test_func_as_dict_keyYs9��������$�&�	�����4�6��E�*�*�*�*�*rN)rrr	r�r�r�r�r�r
rrr�r�7se������K�K�K�2�2�2� M�M�M�.�.�.�+�+�+�+�+rr�c��eZdZd�Zd�ZdS)�FunctionDocstringTestc�\�|�|jjd��d}||j_||jj_|�|jj|��|�|jjj|��|�|jjd|t��dS)NzA test method that does nothing�__doc__)r5r&r�r"r!r'r1rM)r �docstrs  r�test_set_docstring_attrz-FunctionDocstringTest.test_set_docstring_attras����������.�.�.�2������!������������0�0�0�������*�F�3�3�3����T�W�Y�	�6�>�J�J�J�J�Jrc�l�d|j_|j`|�|jjd��dS)Nz
The docstring)r&r�r5rs r�test_delete_docstringz+FunctionDocstringTest.test_delete_docstringjs2��(�����F�N��������.�.�.�.�.rN)rrr	r�r�r
rrr�r�`s5������K�K�K�/�/�/�/�/rr�c�.��	�fd�}|�|jdS)Nc�&��t���dSrrgris�rrjzcell.<locals>.fr����
�a�����rr�rn)r/rjr!s  @rrmrmps1���3������
�A��=���rTc�2��	�fd�}|sd�|jdS)Nc�&��t���dSrrgris�rrjzempty_cell.<locals>.fyr�ri�rr�)�emptyrjr!s  @r�
empty_cellr�ws;���������
�����=���rc��eZdZd�ZdS)�CellTestc��|�td��td��k��|�t��td��k��|�t��t��k��|�td��td��k��|�td��t��k��dS)NrJr%�saturdayi���gB�T)�
assertTruermr�rs r�test_comparisonzCellTest.test_comparison�s���
	
����Q���$�q�'�'�)�*�*�*����
���t�J�'7�'7�7�8�8�8����
���
���4�5�5�5�����S�	�	�T�%�[�[�0�1�1�1�����T�
�
�Z�\�\�1�2�2�2�2�2rN)rrr	r�r
rrr�r��s#������	3�	3�	3�	3�	3rr�c��eZdZd�ZdS)�StaticMethodAttrsTestc��d�}t|��}|�|j|u��t|��}|�|j|u��dS)Nc��dSrr
r
rrrjz4StaticMethodAttrsTest.test_func_attribute.<locals>.f�s���Dr)�classmethodr�r��staticmethod)r rjrsrTs    r�test_func_attributez)StaticMethodAttrsTest.test_func_attribute�s_��	�	�	�
��N�N������
�a��(�(�(���O�O������
�a��(�(�(�(�(rN)rrr	r�r
rrr�r��s#������)�)�)�)�)rr�c��eZdZd�ZdS)�BuiltinFunctionPropertiesTestc�>�ddl}|�tjd��|�|jjd��|�tjjd��|�tjjd��|�tj	jd��|�tj	jd��|�gd�jjd	��|�d
dijjd��dS)
NrrS�timez
dict.fromkeyszfloat.__getformat__z
str.maketranszbytes.maketrans)rlrJr%zlist.append�foo�barzdict.pop)
r�r5rSr	�dict�fromkeys�float�
__getformat__�str�	maketrans�bytes�append�pop)r r�s  r�test_builtin__qualname__z6BuiltinFunctionPropertiesTest.test_builtin__qualname__�s������	
����)�5�1�1�1������/��8�8�8�	
�����3�_�E�E�E�����,�9�.�	0�	0�	0�	
�����3�_�E�E�E������5�7H�I�I�I�	
������)�6�
�F�F�F����%���+�8�*�E�E�E�E�ErN)rrr	r�r
rrr�r��s(������F�F�F�F�Frr��__main__)T)r[rx�unittestr�TestCaserr3r�r�r�r�rmr�r�r�r�r�mainr
rr�<module>rs��������������
"�
"�
"�<�<�<�<�<�H�%�<�<�<�4K,�K,�K,�K,�K,�]�K,�K,�K,�\L�L�L�L�L�]�L�L�L�<,�,�,�,�,�
�,�,�,�<&+�&+�&+�&+�&+�
�&+�&+�&+�R
/�
/�
/�
/�
/�M�
/�
/�
/� ���	�	�	�	�
3�
3�
3�
3�
3�x� �
3�
3�
3�	)�	)�	)�	)�	)�H�-�	)�	)�	)�F�F�F�F�F�H�$5�F�F�F�2�z����H�M�O�O�O�O�O��r