File: //usr/local/lib/python3.10/test/__pycache__/test_modulefinder.cpython-310.opt-1.pyc
o
�i�0 � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z d dl
Z
e�� Zee j
�ej�gZdg d�dgdgdgZdg d�dgdgd gZdg d
�ddgg dgZdg d
�ddgg dgZdg d�g g dgZdg d�g g dgZdddgdgg dgZdddgg g dgZddgg g dgZdg d�dgg dgZdg d�dgg dgZdddgg g d gZdddgg g d!gZd"d"dgg g d#d$�d%� gZd&d'� Z d(d)� Z!G d*d+� d+ej"�Z#e$d,kr�e�%� dS dS )-� 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 *
)r r r r �
__future__a a/__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 Zmymoduler Zblahblaha mymodule.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
) r r r zb.xzb.yzb.zr r �gc�zaj mymodule.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 r r r �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
)
r r za.sysr r r
r r r r za.b.c.fr z 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
r za.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 *
� )r r r zb.modulez�a/__init__.py
a/module.py
import b.module
b/__init__.py
b/module.py
? # SyntaxError: invalid syntax
)r r r zb.cz�a/__init__.py
a/module.py
import c
from b import c
b/__init__.py
b/c.py
Za_utf8Zb_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')
uz a_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')
Za_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
C sX t j�| �}zt �|� W n ty& } z
|jtjkr� W Y d }~nd }~ww t| d�S )N�wb)�os�path�dirname�makedirs�OSError�errno�EEXIST�open)r r �e� r �3/usr/local/lib/python3.10/test/test_modulefinder.py� open_file% s ���
r! c C s� d }zM| � � D ]=}t|�tkr|�d�}|�d�s|�d�r(|�|�� d � q|r.|�� t|�tkr9|�d�}t t
j�t
|�� ��}qW |rN|�� d S d S |rW|�� w w )Nr � � �
)�
splitlines�type�bytes�encode�
startswith�write�strip�close�decoder! r r �join�TEST_DIR)�sourceZofi�liner r r �create_package/ s$
��
�r2 c @ s� e Zd Zddg ejfdd�Zdd� Zdd� Zd d
� Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'S )(�ModuleFinderTestFr c C s� |\}}}} }
t |
� z=|t||d�}|�|� |r|�� tt|��}t|j�}| �||� |�� \}
}| �|
|� | �|| � W t �
t� d S t �
t� w )N)r �debug�
replace_paths)r2 � TEST_PATHZimport_hook�report�sorted�set�modulesZassertEqualZany_missing_maybe�shutil�rmtreer/ )�self�infor7 r4 r5 �modulefinder_classZimport_thisr: �missingZ
maybe_missingr0 Zmf�foundZbad�mayber r r �_do_testB s �
zModuleFinderTest._do_testc C � | � t� d S �N)rC �package_test�r= r r r �test_package` � zModuleFinderTest.test_packagec C rD rE )rC �
maybe_testrG r r r �
test_maybec rI zModuleFinderTest.test_maybec C rD rE )rC �maybe_test_newrG r r r �test_maybe_newf rI zModuleFinderTest.test_maybe_newc C rD rE )rC �absolute_import_testrG r r r �test_absolute_importsi rI z&ModuleFinderTest.test_absolute_importsc C rD rE )rC �relative_import_testrG r r r �test_relative_importsl rI z&ModuleFinderTest.test_relative_importsc C rD rE )rC �relative_import_test_2rG r r r �test_relative_imports_2o rI z(ModuleFinderTest.test_relative_imports_2c C rD rE )rC �relative_import_test_3rG r r r �test_relative_imports_3r rI z(ModuleFinderTest.test_relative_imports_3c C rD rE )rC �relative_import_test_4rG r r r �test_relative_imports_4u rI z(ModuleFinderTest.test_relative_imports_4c C rD rE )rC �syntax_error_testrG r r r �test_syntax_errorx rI z"ModuleFinderTest.test_syntax_errorc C rD rE )rC �same_name_as_bad_testrG r r r �test_same_name_as_bad{ rI z&ModuleFinderTest.test_same_name_as_badc C s� t j�td�}|tjjd }|tjjd }t|��}|� d�
d�� W d � n1 s.w Y tj||d� t �
|� | �t� d S )Nr r ztesting_modulefinder = True
r )�cfile)r r r. r/ � importlib� machinery�SOURCE_SUFFIXES�BYTECODE_SUFFIXESr! r* r( �
py_compile�compile�removerC �
bytecode_test)r= � base_path�source_path�
bytecode_path�filer r r �
test_bytecode~ s
�
zModuleFinderTest.test_bytecodec C s� t j�tdd�}t j�tdd�}t�� �}| jtd||fgd� W d � n1 s*w Y |�� }d||f }| � ||� d S )Nr z module.pyzspam.py� )r4 r5 zco_filename %r changed to %r)
r r r. r/ r Zcaptured_stdoutrC rJ �getvalueZassertIn)r= Zold_path�new_path�outputZexpectedr r r �test_replace_paths� s
��z#ModuleFinderTest.test_replace_pathsc C s, dddgg g dt td�� g}| �|� d S )Nr r zVa.py
%r
import b
b.py
i )�list�rangerC )r= Zextended_opargs_testr r r �test_extended_opargs� s
��
z%ModuleFinderTest.test_extended_opargsc C rD rE )rC �coding_default_utf8_testrG r r r �test_coding_default_utf8� rI z)ModuleFinderTest.test_coding_default_utf8c C rD rE )rC �coding_explicit_utf8_testrG r r r �test_coding_explicit_utf8� rI z*ModuleFinderTest.test_coding_explicit_utf8c C rD rE )rC �coding_explicit_cp1252_testrG r r r �test_coding_explicit_cp1252� rI z,ModuleFinderTest.test_coding_explicit_cp1252c C s$ G dd� dt j�}| jt|d� d S )Nc s( e Zd Z� fdd�Z� fdd�Z� ZS )zAModuleFinderTest.test_load_module_api.<locals>.CheckLoadModuleApic s t � j|i |�� d S rE )�super�__init__)r= �args�kwds�� __class__r r ry � s zJModuleFinderTest.test_load_module_api.<locals>.CheckLoadModuleApi.__init__c s |\}}}t � �||||�S rE )rx �load_module)r= Zfqname�fp�pathname� file_info�suffix�moder&