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

�Ke�0����ddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
Z
dgd�dgdgdgZdgd�dgdgd	gZdgd
�ddggdgZ
dgd
�ddggdgZdgd�ggdgZdgd�ggdgZdddgdggdgZdddgggdgZddgggdgZdgd�dggdgZdgd�dggdgZdddgggd gZdddgggd!gZd"d"dgggd#d$�d%��zgZd&�Zd'�ZGd(�d)ej��Zed*krej��dSdS)+�N)�support�a.module)�ar�sys�b�czb.somethingz�a/__init__.py
a/module.py
                                from b import something
                                from c import something
b/__init__.py
                                from sys import *
)rrrr�
__future__aa/__init__.py
a/module.py
                                from b import something
                                from c import something
b/__init__.py
                                from __future__ import absolute_import
                                from sys import *
)r�a.bza.cr�mymoduler�blahblahamymodule.py
a/__init__.py
                                import blahblah
                                from a import b
                                import c
a/module.py
                                import sys
                                from a import b as x
                                from a.c import sillyname
a/b.py
a/c.py
                                from a.module import x
                                import mymodule as sillyname
                                from sys import version_info
)	rrrzb.xzb.yzb.zr	r�gc�zajmymodule.py
a/__init__.py
a/module.py
                                from __future__ import absolute_import
                                import sys # sys
                                import blahblah # fails
                                import gc # gc
                                import b.x # b.x
                                from b import y # b.y
                                from b.z import * # b.z.*
a/gc.py
a/sys.py
                                import mymodule
a/b/__init__.py
a/b/x.py
a/b/y.py
a/b/z.py
b/__init__.py
                                import z
b/unused.py
b/x.py
b/y.py
b/z.py
)r	rrr
�a.b.y�a.b.z�a.b.c�
a.b.c.moduleC�a.b.c.d�a.b.c.e�a.b.xr
a�mymodule.py
a/__init__.py
                                from .b import y, z # a.b.y, a.b.z
a/module.py
                                from __future__ import absolute_import # __future__
                                import gc # gc
a/gc.py
a/sys.py
a/b/__init__.py
                                from ..b import x # a.b.x
                                #from a.b.c import moduleC
                                from .c import moduleC # a.b.moduleC
a/b/x.py
a/b/y.py
a/b/z.py
a/b/g.py
a/b/c/__init__.py
                                from ..c import e # a.b.c.e
a/b/c/moduleC.py
                                from ..c import d # a.b.c.d
a/b/c/d.py
a/b/c/e.py
a/b/c/x.py
)
rrza.sysr
rrrrrrza.b.c.frz	a.anothera�mymodule.py
a/__init__.py
                                from . import sys # a.sys
a/another.py
a/module.py
                                from .b import y, z # a.b.y, a.b.z
a/gc.py
a/sys.py
a/b/__init__.py
                                from .c import moduleC # a.b.c.moduleC
                                from .c import d # a.b.c.d
a/b/x.py
a/b/y.py
a/b/z.py
a/b/c/__init__.py
                                from . import e # a.b.c.e
a/b/c/moduleC.py
                                #
                                from . import f   # a.b.c.f
                                from .. import x  # a.b.x
                                from ... import another # a.another
a/b/c/d.py
a/b/c/e.py
a/b/c/f.py
rza.barz�a/__init__.py
                                def foo(): pass
a/module.py
                                from . import foo
                                from . import bar
zza/__init__.py
                                def foo(): pass
a/module.py
                                from . import *
�)rrrzb.modulez�a/__init__.py
a/module.py
                                import b.module
b/__init__.py
b/module.py
                                ?  # SyntaxError: invalid syntax
)rrrzb.cz�a/__init__.py
a/module.py
                                import c
                                from b import c
b/__init__.py
b/c.py
�a_utf8�b_utf8u�a_utf8.py
                                # use the default of utf8
                                print('Unicode test A code point 2090 ₐ that is not valid in cp1252')
                                import b_utf8
b_utf8.py
                                # use the default of utf8
                                print('Unicode test B code point 2090 ₐ that is not valid in cp1252')
uza_utf8.py
                                # coding=utf8
                                print('Unicode test A code point 2090 ₐ that is not valid in cp1252')
                                import b_utf8
b_utf8.py
                                # use the default of utf8
                                print('Unicode test B code point 2090 ₐ that is not valid in cp1252')
�a_cp1252s�a_cp1252.py
                                # coding=cp1252
                                # 0xe2 is not allowed in utf8
                                print('CP1252 test P�t�')
                                import b_utf8
u�b_utf8.py
                                # use the default of utf8
                                print('Unicode test A code point 2090 ₐ that is not valid in cp1252')
�utf-8c���tj�|��}	tj|��n-#t$r }|jt
jkr�Yd}~nd}~wwxYwt|d��S)N�wb)�os�path�dirname�makedirs�OSError�errno�EEXIST�open)rr�es   �@/usr/local/apps/python3/lib/python3.11/test/test_modulefinder.py�	open_filer'"s����g�o�o�d�#�#�G��
��G�����������7�e�l�"�"��#�"�"�"�"�����������d���s�6�
A �A�A c��d}	|���D�]}t|��tkr|�d��}|�d��s|�d��r+|�|���dz����|r|���t|��tkr|�d��}ttj�||�������}��		|r|���dSdS#|r|���wwxYw)Nr� �	�
)
�
splitlines�type�bytes�encode�
startswith�write�strip�close�decoder'rr�join)�test_dir�source�ofi�lines    r&�create_packager:,s>��
�C���%�%�'�'�
	F�
	F�D��D�z�z�U�"�"��{�{�7�+�+�����t�$�$�
F�����(>�(>�
F��	�	�$�*�*�,�,��.�/�/�/�/�� ��I�I�K�K�K���:�:��&�&��;�;�w�/�/�D������X�t�z�z�|�|� D� D�E�E���
	F��	��I�I�K�K�K�K�K�	�	��3�	��I�I�K�K�K�K�	���s�DD<�<Ec��eZdZd�Zd�Zddgejfd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�ModuleFinderTestc��tj��|_|jtj�tj��g|_dS�N)�tempfile�mkdtempr6rrr�__file__�	test_path��selfs r&�setUpzModuleFinderTest.setUp?s5�� �(�*�*��
��-������9J�)K�)K�L�����c�8�tj|j��dSr>)�shutil�rmtreer6rCs r&�tearDownzModuleFinderTest.tearDownCs���
�d�m�$�$�$�$�$rFFrc���|\}}}}	}
t|j|
��||j||���}|�|��|r|���tt
|����}t|j��}|�||��|�	��\}
}|�|
|��|�||	��dS)N)r�debug�
replace_paths)
r:r6rB�import_hook�report�sorted�set�modules�assertEqual�any_missing_maybe)rD�inforOrLrM�modulefinder_class�import_thisrR�missing�
maybe_missingr7�mf�found�bad�maybes               r&�_do_testzModuleFinderTest._do_testFs���?C�<��W�g�}�f��t�}�f�-�-�-�
�
�T�^�5�6C�E�E�E��
���{�#�#�#��	��I�I�K�K�K���W���&�&���r�z�"�"�������(�(�(��)�)�+�+�
��U�����g�&�&�&�����
�.�.�.�.�.rFc�:�|�t��dSr>)r^�package_testrCs r&�test_packagezModuleFinderTest.test_packageas���
�
�l�#�#�#�#�#rFc�:�|�t��dSr>)r^�
maybe_testrCs r&�
test_maybezModuleFinderTest.test_maybeds���
�
�j�!�!�!�!�!rFc�:�|�t��dSr>)r^�maybe_test_newrCs r&�test_maybe_newzModuleFinderTest.test_maybe_newgs���
�
�n�%�%�%�%�%rFc�:�|�t��dSr>)r^�absolute_import_testrCs r&�test_absolute_importsz&ModuleFinderTest.test_absolute_importsj����
�
�*�+�+�+�+�+rFc�:�|�t��dSr>)r^�relative_import_testrCs r&�test_relative_importsz&ModuleFinderTest.test_relative_importsmrkrFc�:�|�t��dSr>)r^�relative_import_test_2rCs r&�test_relative_imports_2z(ModuleFinderTest.test_relative_imports_2p����
�
�,�-�-�-�-�-rFc�:�|�t��dSr>)r^�relative_import_test_3rCs r&�test_relative_imports_3z(ModuleFinderTest.test_relative_imports_3srrrFc�:�|�t��dSr>)r^�relative_import_test_4rCs r&�test_relative_imports_4z(ModuleFinderTest.test_relative_imports_4vrrrFc�:�|�t��dSr>)r^�syntax_error_testrCs r&�test_syntax_errorz"ModuleFinderTest.test_syntax_errorys���
�
�'�(�(�(�(�(rFc�:�|�t��dSr>)r^�same_name_as_bad_testrCs r&�test_same_name_as_badz&ModuleFinderTest.test_same_name_as_bad|s���
�
�+�,�,�,�,�,rFc���tj�|jd��}|tjjdz}|tjjdz}t|��5}|�	d�
d����ddd��n#1swxYwYtj||���tj
|��|�t��dS)Nrrztesting_modulefinder = True
r)�cfile)rrr5r6�	importlib�	machinery�SOURCE_SUFFIXES�BYTECODE_SUFFIXESr'r1r/�
py_compile�compile�remover^�
bytecode_test)rD�	base_path�source_path�
bytecode_path�files     r&�
test_bytecodezModuleFinderTest.test_bytecodes���G�L�L����4�4�	��)�"5�"E�a�"H�H��!�I�$7�$I�!�$L�L�
�
�{�
#�
#�	H�t��J�J�6�=�=�g�F�F�G�G�G�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H���;�m�<�<�<�<�
�	�+�����
�
�m�$�$�$�$�$s�))B�B"�%B"c��tj�|jdd��}tj�|jdd��}t	j��5}|�td||fg���ddd��n#1swxYwY|���}d|�d|��}|�	||��dS)Nrz	module.pyzspam.py�)rLrMzco_filename z changed to )
rrr5r6r�captured_stdoutr^rc�getvalue�assertIn)rD�old_path�new_path�output�expecteds     r&�test_replace_pathsz#ModuleFinderTest.test_replace_paths�s���7�<�<��
�s�K�@�@���7�<�<��
�s�I�>�>��
�
$�
&�
&�	@�&��M�M�*�A�*2�H�)=�(>�
�
@�
@�
@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@����"�"���5=�X�X�x�x�H���
�
�h��'�'�'�'�'s� !B
�
B�Bc
�|�dddgggdttd����zg}|�|��dS)NrrzVa.py
                                %r
                                import b
b.py
i)�list�ranger^)rD�extended_opargs_tests  r&�test_extended_opargsz%ModuleFinderTest.test_extended_opargs�sQ���
�#�J���
�
�5��<�<���
�		 ��	
�
�
�*�+�+�+�+�+rFc�:�|�t��dSr>)r^�coding_default_utf8_testrCs r&�test_coding_default_utf8z)ModuleFinderTest.test_coding_default_utf8�s���
�
�.�/�/�/�/�/rFc�:�|�t��dSr>)r^�coding_explicit_utf8_testrCs r&�test_coding_explicit_utf8z*ModuleFinderTest.test_coding_explicit_utf8�s���
�
�/�0�0�0�0�0rFc�:�|�t��dSr>)r^�coding_explicit_cp1252_testrCs r&�test_coding_explicit_cp1252z,ModuleFinderTest.test_coding_explicit_cp1252�s���
�
�1�2�2�2�2�2rFc�n�Gd�dtj��}|�t|���dS)Nc�(��eZdZ�fd�Z�fd�Z�xZS)�AModuleFinderTest.test_load_module_api.<locals>.CheckLoadModuleApic�:��t��j|i|��dSr>)�super�__init__)rD�args�kwds�	__class__s   �r&r�zJModuleFinderTest.test_load_module_api.<locals>.CheckLoadModuleApi.__init__�s%��� ���� �$�/�$�/�/�/�/�/rFc�X��|\}}}t���||||��Sr>)r��load_module)	rD�fqname�fp�pathname�	file_info�suffix�moder-r�s	        �r&r�zMModuleFinderTest.test_load_module_api.<locals>.CheckLoadModuleApi.load_module�s-���%.�"���d��w�w�*�*�6�2�x��K�K�KrF)�__name__�
__module__�__qualname__r�r��
__classcell__)r�s@r&�CheckLoadModuleApir��sZ�������
0�
0�
0�
0�
0�
L�
L�
L�
L�
L�
L�
L�
L�
LrFr�)rV)�modulefinder�ModuleFinderr^ri)rDr�s  r&�test_load_module_apiz%ModuleFinderTest.test_load_module_api�sW��	L�	L�	L�	L�	L��!:�	L�	L�	L�	
�
�
�*�?Q�
�R�R�R�R�RrFN)r�r�r�rErJr�r�r^rardrgrjrnrqrurxr{r~r�r�r�r�r�r�r��rFr&r<r<>s\������M�M�M�%�%�%�%*��"�Ye�Yr�/�/�/�/�6$�$�$�"�"�"�&�&�&�,�,�,�,�,�,�.�.�.�.�.�.�.�.�.�)�)�)�-�-�-�%�%�%�(�(�(�,�,�,�0�0�0�1�1�1�3�3�3�
S�
S�
S�
S�
SrFr<�__main__) rr"�importlib.machineryr�r�rH�unittestr?�testrr�rcrfr`rirmrprtrwr�rzr}r�r�r/r�r'r:�TestCaser<r��mainr�rFr&�<module>r�s���	�	�	�	�������������
�
�
�
�������������������$�
�
�
��E�M�?��
�
� �����E�M�?��
�� �6�6�6����r��	��,� � � ����r��
��B�������"��J�������%��P��*���I�������*�����
����E�����
������L�"��	���!�!�!��E�2��	��
�
�x�����	��
�
�x�����	�����������F�7�O�O�
�	�� ������$uS�uS�uS�uS�uS�x�(�uS�uS�uS�n�z����H�M�O�O�O�O�O��rF