Sindbad~EG File Manager
a
��g�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,k�r�e�%� 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 n2 tyL } z|jtjkr8� W Y d }~n
d }~0 0 t| d�S )N�wb)�os�path�dirname�makedirs�OSError�errno�EEXIST�open)r r �e� r �2/usr/local/lib/python3.9/test/test_modulefinder.py� open_file% s r! c C s� d }z�| � � D ]z}t|�tkr(|�d�}|�d�s<|�d�rP|�|�� d � q|r\|�� t|�tkrr|�d�}t t
j�t
|�� ��}qW |r�|�� n|r�|�� 0 d S )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 |
� zx|t||d�}|�|� |r<|�� tt|��}t|j�}| �||� |�� \}
}| �|
|� | �|| � W t �
t� nt �
t� 0 d S )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 s | � t� d S �N)rC �package_test�r= r r r �test_package` s zModuleFinderTest.test_packagec C s | � t� d S rD )rC �
maybe_testrF r r r �
test_maybec s zModuleFinderTest.test_maybec C s | � t� d S rD )rC �maybe_test_newrF r r r �test_maybe_newf s zModuleFinderTest.test_maybe_newc C s | � t� d S rD )rC �absolute_import_testrF r r r �test_absolute_importsi s z&ModuleFinderTest.test_absolute_importsc C s | � t� d S rD )rC �relative_import_testrF r r r �test_relative_importsl s z&ModuleFinderTest.test_relative_importsc C s | � t� d S rD )rC �relative_import_test_2rF r r r �test_relative_imports_2o s z(ModuleFinderTest.test_relative_imports_2c C s | � t� d S rD )rC �relative_import_test_3rF r r r �test_relative_imports_3r s z(ModuleFinderTest.test_relative_imports_3c C s | � t� d S rD )rC �relative_import_test_4rF r r r �test_relative_imports_4u s z(ModuleFinderTest.test_relative_imports_4c C s | � t� d S rD )rC �syntax_error_testrF r r r �test_syntax_errorx s z"ModuleFinderTest.test_syntax_errorc C s | � t� d S rD )rC �same_name_as_bad_testrF r r r �test_same_name_as_bad{ s z&ModuleFinderTest.test_same_name_as_badc C s� t j�td�}|tjjd }|tjjd }t|�� }|� d�
d�� W d � n1 s\0 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 sT0 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 rH �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 s | � t� d S rD )rC �coding_default_utf8_testrF r r r �test_coding_default_utf8� s z)ModuleFinderTest.test_coding_default_utf8c C s | � t� d S rD )rC �coding_explicit_utf8_testrF r r r �test_coding_explicit_utf8� s z*ModuleFinderTest.test_coding_explicit_utf8c C s | � t� d S rD )rC �coding_explicit_cp1252_testrF r r r �test_coding_explicit_cp1252� s 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 rD )�super�__init__)r= �args�kwds�� __class__r r rw � s zJModuleFinderTest.test_load_module_api.<locals>.CheckLoadModuleApi.__init__c s |\}}}t � �||||�S rD )rv �load_module)r= Zfqname�fp�pathname� file_info�suffix�moder&