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

�Ke�3����ddlZddlZddlmZddlmZddlmZddlZee��Z	Gd�d��Z
Gd�d��ZGd	�d
ej��Z
edkrej��dSdS)�N)�
gc_collect)�
import_helper)�assert_python_okc�$�eZdZed���ZdS)�
FullLoaderc�6�d�|j��S)Nz<module '{}' (crafted)>)�format�__name__)�cls�ms  �:/usr/local/apps/python3/lib/python3.11/test/test_module.py�module_reprzFullLoader.module_reprs��(�/�/��
�;�;�;�N)r
�
__module__�__qualname__�classmethodr�rr
rrs-�������<�<��[�<�<�<rrc��eZdZdS)�
BareLoaderN)r
rrrrr
rrs�������Drrc���eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%S)&�ModuleTestsc��t�t��}|�t|jt
����|�t|��g��	|j}|�	dt|��z��n#t$rYnwxYw|�|jtj��dS)Nz
__name__ = %s)
�
ModuleType�__new__�
assertTrue�
isinstance�__dict__�dict�assertEqual�dirr
�fail�repr�AttributeError�__doc__)�self�foo�ss   r
�test_uninitializedzModuleTests.test_uninitializeds���� � ��,�,�����
�3�<��6�6�7�7�7�����S���2�&�&�&�	���A��I�I�o��Q���/�0�0�0�0���	�	�	��D�	���������j�&8�9�9�9�9�9s�1,B�
B+�*B+c��t�t��}|�tdt|d��dS)Nz"module has no attribute 'not_here'�not_here)rr�assertRaisesRegexr#�getattr�r%r&s  r
�"test_uninitialized_missing_getattrz.ModuleTests.test_uninitialized_missing_getattr"sF��� � ��,�,������ D���j�	*�	*�	*�	*�	*rc�j�td��}|�tdt|d��dS)Nr&z(module 'foo' has no attribute 'not_here'r*)rr+r#r,r-s  r
�test_missing_getattrz ModuleTests.test_missing_getattr*s@����������� J���j�	*�	*�	*�	*�	*rc	�t�td��}|�|jd��|�|jd��|�|jd��|�|jd��|�|jd��|�|jdddddd���dS)Nr&�r
r$�
__loader__�__package__�__spec__)	rrr
r$�assertIsr3r4r5rr-s  r
�test_no_docstringzModuleTests.test_no_docstring2s�������������u�-�-�-������d�+�+�+��
�
�c�n�d�+�+�+��
�
�c�o�t�,�,�,��
�
�c�l�D�)�)�)������E�d�6:�4�48�(:�(:�	;�	;�	;�	;�	;rc	���tdd��}|�|jd��|�|jd��|�|jdddddd���dS)Nr&�foodocr2�rrr
r$rr-s  r
�test_ascii_docstringz ModuleTests.test_ascii_docstring>s~�����)�)�������u�-�-�-������h�/�/�/������&+��(,�T�&*�,�,�	-�	-�	-�	-�	-rc	���tdd��}|�|jd��|�|jd��|�|jdddddd���dS)Nr&�	foodocሴr2r:r-s  r
�test_unicode_docstringz"ModuleTests.test_unicode_docstringHs~�����/�/�������u�-�-�-������n�5�5�5������&+��(,�T�&*�,�,�	-�	-�	-�	-�	-rc
��tdd��}d|_|j}|�dd��|�|jd��|�|jd��|�|jd��|�|jddddddd���|�|j|u��dS)Nr&r=�*r9)r
r$�barr3r4r5)rrAr�__init__rr
r$r)r%r&�ds   r
�test_reinitzModuleTests.test_reinitRs������/�/������L�����U�H�%�%�%������u�-�-�-������h�/�/�/������"�%�%�%������ �X�b�!�$�D�J�J�	K�	K�	K�	
������)�*�*�*�*�*rc�z�d�}t��|�|��jdd��dS)Nc�2�td��}d|_|S)Nr&�)rrA)r&s r
�fz+ModuleTests.test_dont_clear_dict.<locals>.fbs���U�#�#�C��C�G��JrrArG)rrr)r%rHs  r
�test_dont_clear_dictz ModuleTests.test_dont_clear_dict`sE��	�	�	�	������������e�,�a�0�0�0�0�0rc��g}td��}||_d}t||j��~t	��|�|dg��dS)Nr&zwclass A:
    def __init__(self, l):
        self.l = l
    def __del__(self):
        self.l.append(1)
a = A(destroyed)�)r�	destroyed�execrrr)r%rLrr's    r
�test_clear_dict_in_ref_cyclez(ModuleTests.test_clear_dict_in_ref_cycleis`���	��u�������
��	
�Q��
����
���������Q�C�(�(�(�(�(rc���td��}tj|��}|�|��|��~t	��|�|��d��dS�Nr&)r�weakref�refr6r)r%r�wrs   r
�test_weakrefzModuleTests.test_weakrefxsb���u����
�[��^�^���
�
�b�b�d�d�A����
������
�
�b�b�d�d�D�!�!�!�!�!rc�z�ddlm}ddlm}|�|d��|�|jd��|�|jd��|�td��5|jddd��n#1swxYwY|�|j	d��tjd=dS)	Nr)�testz
There is testrK�z Deprecated, use whatever insteadzThere is whatever�test.good_getattr)�test.good_getattr�good_getattrrVr�x�yr+r#�yolo�whatever�sys�modules)r%�ggarVs   r
�test_module_getattrzModuleTests.test_module_getattr�s��'�'�'�'�'�'�*�*�*�*�*�*������/�/�/�������"�"�"�������"�"�"�
�
#�
#�N�$F�H�H�	�	��H�H�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
�����':�;�;�;��K�+�,�,�,s�4B�B�Bc���ddlm}ddlm}|�|jd��|�|jd��|�t��5|jddd��n#1swxYwY|�t��5|jddd��n#1swxYwYtj
d=dtj
vrtj
d=dSdS)Nr��bad_getattr2rK�test.bad_getattr�test.bad_getattr2)�test.bad_getattr�bad_getattrrVrerr[�assertRaises�	TypeError�noper_r`�r%�bgares   r
�test_module_getattr_errorsz&ModuleTests.test_module_getattr_errors�si��&�&�&�&�&�&�%�%�%�%�%�%�������"�"�"�������+�+�+�
�
�
�y�
)�
)�	�	��H�H�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�y�
)�
)�	�	����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��K�*�+��#�+�-�-���/�0�0�0�.�-s$�A1�1A5�8A5�B*�*B.�1B.c�v�ddlm}|�t|��gd���tjd=dS)Nr)�a�b�crX)rYrZrr r_r`)r%ras  r
�test_module_dirzModuleTests.test_module_dir�sE��'�'�'�'�'�'�����S���?�?�?�3�3�3��K�+�,�,�,rc�v�ddlm}ddlm}|�t
��5t
|��ddd��n#1swxYwY|�t
��5t
|��ddd��n#1swxYwYtjd=dtjvrtjd=dSdS)Nrrdrfrg)	rhrirVrerjrkr r_r`rms   r
�test_module_dir_errorsz"ModuleTests.test_module_dir_errors�sB��&�&�&�&�&�&�%�%�%�%�%�%�
�
�
�y�
)�
)�	�	���H�H�H�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�y�
)�
)�	�	������	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��K�*�+��#�+�-�-���/�0�0�0�.�-s#�A�A�
A�(B�B�Bc�0�ddlm}|�t��5|jddd��n#1swxYwY|�t��5|jddd��n#1swxYwYdtjvrtjd=dSdS)Nr)�bad_getattr3ztest.bad_getattr3)rVrxrjr#�one�
delgetattrr_r`)r%rxs  r
�test_module_getattr_trickyz&ModuleTests.test_module_getattr_tricky�s��%�%�%�%�%�%�
�
�
�~�
.�
.�	�	����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�~�
.�
.�	$�	$��#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��#�+�-�-���/�0�0�0�.�-s�5�9�9�A.�.A2�5A2c�n�td��}|`|�t|��d��dS)Nr&z<module '?'>)rr
rr"�r%rs  r
�test_module_repr_minimalz$ModuleTests.test_module_repr_minimal�s6���u����
�J�����a���.�1�1�1�1�1rc�j�td��}|�t|��d��dS�Nr&z<module 'foo'>�rrr"r}s  r
�test_module_repr_with_namez&ModuleTests.test_module_repr_with_name�s2���u��������a���"2�3�3�3�3�3rc�x�td��}d|_|�t|��d��dS�Nr&�/tmp/foo.pyz!<module 'foo' from '/tmp/foo.py'>)r�__file__rr"r}s  r
�'test_module_repr_with_name_and_filenamez3ModuleTests.test_module_repr_with_name_and_filename�s9���u����"��
�����a���"E�F�F�F�F�Frc�|�td��}|`d|_|�t	|��d��dS)Nr&r�z<module '?' from '/tmp/foo.py'>)rr
r�rr"r}s  r
�#test_module_repr_with_filename_onlyz/ModuleTests.test_module_repr_with_filename_only�s>���u����
�J�"��
�����a���"C�D�D�D�D�Drc�j�td��}|�t|��d��dSr�r�r}s  r
�$test_module_repr_with_loader_as_Nonez0ModuleTests.test_module_repr_with_loader_as_None�s2���u��������a���"2�3�3�3�3�3rc���td��}|`t|_t	t��}|�t	|��d�|����dS�Nr&z<module '?' ({})>)rr
rr3r"rr	�r%r�loader_reprs   r
�-test_module_repr_with_bare_loader_but_no_namez9ModuleTests.test_module_repr_with_bare_loader_but_no_name�sd���u����
�J�!����:�&�&�������G�G�(�/�/��<�<�	>�	>�	>�	>�	>rc���td��}|`t|_t	t��}|�t	|��d�|����dSr�)rr
rr3r"rr	r�s   r
�-test_module_repr_with_full_loader_but_no_namez9ModuleTests.test_module_repr_with_full_loader_but_no_name�sf��
�u����
�J�!����:�&�&�������G�G�(�/�/��<�<�	>�	>�	>�	>�	>rc���td��}t|_tt��}|�t|��d�|����dS)Nr&z<module 'foo' ({})>)rrr3r"rr	)r%rrs   r
�!test_module_repr_with_bare_loaderz-ModuleTests.test_module_repr_with_bare_loader�sd���u����!����:�&�&�������G�G�*�1�1�+�>�>�	@�	@�	@�	@�	@rc��td��}t|_|�t	|��d��dS)Nr&�<module 'foo' (crafted)>)rrr3rr"r}s  r
�!test_module_repr_with_full_loaderz-ModuleTests.test_module_repr_with_full_loader�sD���u����!��������G�G�/�	1�	1�	1�	1�	1rc��td��}t|_d|_|�t|��d��dSr�)rrr3r�rr"r}s  r
�.test_module_repr_with_bare_loader_and_filenamez:ModuleTests.test_module_repr_with_bare_loader_and_filename�s@���u����!���"��
�����a���"E�F�F�F�F�Frc��td��}t|_d|_|�t|��d��dS)Nr&r�r�)rrr3r�rr"r}s  r
�.test_module_repr_with_full_loader_and_filenamez:ModuleTests.test_module_repr_with_full_loader_and_filename�s@���u����!���"��
�����a���"<�=�=�=�=�=rc�V�|�tt��d��dS)Nz<module 'sys' (built-in)>)rr"r_)r%s r
�test_module_repr_builtinz$ModuleTests.test_module_repr_builtins%������c���$?�@�@�@�@�@rc�8�tt��}d}d}|�|dt|���|d�||����|�|t|��d�|d�||����dS)Nz<module 'unittest' from 'z
__init__.py'>z{!r} does not start with {!r}z{!r} does not end with {!r})r"�unittestr�lenr	)r%�r�starts_with�	ends_withs    r
�test_module_repr_sourcez#ModuleTests.test_module_repr_sources�����N�N��1��#�	�����,�C��,�,�,�-�{�8�?�?��;�O�O�	Q�	Q�	Q�����C�	�N�N�?�+�+�,�i�6�=�=�a��K�K�	M�	M�	M�	M�	Mrc���tdd��\}}}|�|��|���}|�t	|��hd���dS)Nz-czfrom test import final_a>�x = a�x = b�	len = len�
final_a.x = a�
final_b.x = b�shutil.rmtree = rmtree)r�assertFalse�
splitlinesr�set)r%�rc�out�err�liness     r
�$test_module_finalization_at_shutdownz0ModuleTests.test_module_finalization_at_shutdown
st��'��.H�I�I���C������������ � ������U���&'�&'�&'�	(�	(�	(�	(�	(rc���Gd�d���G�fd�dt��}|�tt|d��d��dS)Nc��eZdZd�ZdS)�;ModuleTests.test_descriptor_errors_propagate.<locals>.Descrc��t��N)�RuntimeError)r%�o�ts   r
�__get__zCModuleTests.test_descriptor_errors_propagate.<locals>.Descr.__get__s��"�"rN)r
rrr�rrr
�Descrr�s#������
#�
#�
#�
#�
#rr�c�$��eZdZ���ZdS)�7ModuleTests.test_descriptor_errors_propagate.<locals>.MN)r
rr�melon)r�s�r
�Mr�s��������E�G�G�E�E�Err��mymodr�)rrjr�r,)r%r�r�s  @r
� test_descriptor_errors_propagatez,ModuleTests.test_descriptor_errors_propagates����	#�	#�	#�	#�	#�	#�	#�	#�	�	�	�	�	�	�	�
�	�	�	����,����7���W�E�E�E�E�Erc�^�td��}td��D]�}|�d|jv��|j}|�d|jv��|�|j|��|�|jd|��|dzr|`��|jd=��dS)Nr&rG�__annotations__rW)r�ranger�rr�rr�r%r&�irCs    r
�test_lazy_create_annotationsz(ModuleTests.test_lazy_create_annotations"s���������q���		4�		4�A����.�#�,�>�?�?�?��#�A��O�O�-���=�>�>�>����S�0�!�4�4�4����S�\�*;�<�a�@�@�@��1�u�
4��'�'��L�!2�3�3�		4�		4rc�p�td��}td��D]�}|�d|jv��dti}||_|�d|jv��|�|j|��|�|jd|��|dzr|`��|jd=��dS)Nr&rGr�rqrW)rr�r�r�intr�rrr�s    r
�test_setting_annotationsz$ModuleTests.test_setting_annotations2s���������q���
	4�
	4�A����.�#�,�>�?�?�?��c�
�A�"#�C���O�O�-���=�>�>�>����S�0�!�4�4�4����S�\�*;�<�a�@�@�@��1�u�
4��'�'��L�!2�3�3�
	4�
	4rc��td��}i|_|`|�t��5|`ddd��dS#1swxYwYdSrP)rr�rjr#r-s  r
�test_annotations_getset_raisesz*ModuleTests.test_annotations_getset_raises@s�������� �����
�
�
�~�
.�
.�	$�	$��#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s�A�A�
Ac��tjd��}|�d|jv��|`|�d|jv��dS)Nztest.ann_module4r�)r�import_fresh_modulerrr�r�)r%�ann_module4s  r
�&test_annotations_are_created_correctlyz2ModuleTests.test_annotations_are_created_correctlyHsW��#�7�8J�K�K�����)�[�-A�A�B�B�B��'����*�k�.B�B�C�C�C�C�Crc���td��}|j}d}td��D](}d|_||jz
}|�d���)|�|d��dS)NrVr�drK�attr)rrr�r��popr)r%rrC�count�_s     r
�test_repeated_attribute_popsz(ModuleTests.test_repeated_attribute_popsOsq��
�v����
�J�����s���	�	�A��A�F��Q�V�O�E�
�E�E�&�M�M�M�M������$�$�$�$�$rc��Gd�dt��}|d��}|�t��5|jddd��n#1swxYwY|�t��5|jddd��n#1swxYwYd\|_|_|�|jd��|�|jd��dS)Nc�"��eZdZdZ�fd�Z�xZS)�=ModuleTests.test_subclass_with_slots.<locals>.ModuleWithSlots)rqrrc�J��t���|��dSr�)�superrB)r%�name�	__class__s  �r
rBzFModuleTests.test_subclass_with_slots.<locals>.ModuleWithSlots.__init__cs!������ � ��&�&�&�&�&r)r
rr�	__slots__rB�
__classcell__)r�s@r
�ModuleWithSlotsr�`s=�������"�I�
'�
'�
'�
'�
'�
'�
'�
'�
'rr�r�)rKrWrKrW)rrjr#rqrrr)r%r�rs   r
�test_subclass_with_slotsz$ModuleTests.test_subclass_with_slots]s`��	'�	'�	'�	'�	'�j�	'�	'�	'�
�O�F�#�#��
�
�
�~�
.�
.�	�	�
�C�C�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�~�
.�
.�	�	�
�C�C�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����Q�S������a� � � ������a� � � � � s#�A
�
A�A�2B�B
�
B
N)'r
rrr(r.r0r7r;r>rDrIrNrTrbrortrvr{r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrsH������:�:�:�*�*�*�*�*�*�
;�
;�
;�-�-�-�-�-�-�+�+�+�1�1�1�
)�
)�
)�"�"�"�
-�
-�
-�1�1�1�-�-�-�
	1�	1�	1�1�1�1�2�2�2�4�4�4�G�G�G�
E�E�E�4�4�4�
>�>�>�
>�
>�
>�@�@�@�1�1�1�G�G�G�>�>�>�A�A�A�M�M�M�(�(�(�F�F�F�4�4�4� 4�4�4�$�$�$�D�D�D�
%�
%�
%�!�!�!�!�!rr�__main__)r�rQ�test.supportrr�test.support.script_helperrr_�typerrr�TestCaserr
�mainrrr
�<module>r�s����������#�#�#�#�#�#�&�&�&�&�&�&�7�7�7�7�7�7�
�
�
�
�
�T�#�Y�Y�
�<�<�<�<�<�<�<�<�
	�	�	�	�	�	�	�	�Y!�Y!�Y!�Y!�Y!�(�#�Y!�Y!�Y!�z
�z����H�M�O�O�O�O�O��r