HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/test_importlib/source/__pycache__/test_finder.cpython-37.opt-1.pyc
B

��gG"�@s�ddlmZddlmZe�d�ZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
Z
ddlZGdd�dej�ZGd	d
�d
e�Zejeed�\ZZGdd
�d
e�Zejeed�\ZZGdd�de�Zejeed�\ZZedkr�e
��dS)�)�abc)�utilzimportlib.machinery�N)�make_legacy_pycc@s�eZdZdZdd�Zdd�Zd"ddd�dd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Ze�ejdkd�dd��Zd d!�ZdS)#�FinderTestsaEFor a top-level module, it should just be found directly in the
    directory being searched. This is true for a directory with source
    [top-level source], bytecode [top-level bc], or both [top-level both].
    There is also the possibility that it is a package [top-level package], in
    which case there will be a directory with the module name and an
    __init__.py file. If there is a directory without an __init__.py an
    ImportWarning is returned [empty dir].

    For sub-modules and sub-packages, the same happens as above but only use
    the tail end of the name [sub module] [sub package] [sub empty].

    When there is a conflict between a package and module having the same name
    in the same directory, the package wins out [package over module]. This is
    so that imports of modules within the package can occur rather than trigger
    an import error.

    When there is a package and module with the same name, always pick the
    package over the module [package over module]. This is so that imports from
    the package have the possibility of succeeding.

    cCs2|jj|jjf|jj|jjfg}|jj|f|��S)N)�	machinery�SourceFileLoader�SOURCE_SUFFIXES�SourcelessFileLoader�BYTECODE_SUFFIXES�
FileFinder)�self�root�loader_details�r�B/usr/local/lib/python3.7/test/test_importlib/source/test_finder.py�
get_finder)s
zFinderTests.get_findercCs|�|�}|j||dd�S)NT)�loader_only)r�_find)r
r�module�finderrrr�import_0s
zFinderTests.import_N)�compile_�unlinkc	Cs�|dkr|h}tj|���}|r:x|D]}t�||�q$W|r�x\|D]T}t�||�yt||�WqDtk
r�}z|jtj	kr��Wdd}~XYqDXqDW|�
|d|�}|�t|d��|SQRXdS)z�Test the finding of 'test' with the creation of modules listed in
        'create'.

        Any names listed in 'compile_' are byte-compiled. Modules
        listed in 'unlink' have their source files deleted.

        Nz.root�load_module)
r�create_modules�
py_compile�compile�osrr�OSError�errno�ENOENTr�
assertTrue�hasattr)	r
ZtestZcreaterr�mapping�name�error�loaderrrr�run_test4s"

zFinderTests.run_testcCs2|�d�|jddhdhd�|jddhd�dS)NZ	top_level)rr)r)r()r
rrr�test_moduleQs


zFinderTests.test_modulecCs>|�ddh�|jddhdhdhd�|jddhdhd�dS)NZpkgzpkg.__init__)rr)r)r()r
rrr�test_package[s
zFinderTests.test_packagec	CsHt�dd��2}tj�|d�}|�|d�}|�t|d��WdQRXdS)Nzpkg.__init__zpkg.subr)rrr�path�dirnamerr"r#)r
r$�pkg_dirr'rrr�test_module_in_packageesz"FinderTests.test_module_in_packagec	CsLt�dd�}|�2}tj�|d�}|�|d�}|�t|d��WdQRXdS)Nzpkg.__init__zpkg.sub.__init__zpkg.subr)rrrr+r,rr"r#)r
�contextr$r-r'rrr�test_package_in_packagels
z#FinderTests.test_package_in_packagecCs0d}|�|d�|�|h�}|�d|�|��dS)NZ_tempz{0}.__init__�__init__)r(�formatZassertIn�get_filename)r
r%r'rrr�test_package_over_moduletsz$FinderTests.test_package_over_modulec	Cs4t�d�� }|�|dd�}|�|�WdQRXdS)NZblahz.rootZ
sdfsadsadf)rrr�assertIsNone)r
r$Znothingrrr�test_failureyszFinderTests.test_failurec	Csp|j�d|jj|jjf�}tdd��}|�d�WdQRXz$|j|ddd�}|�t|d��Wdt	�
d�XdS)	N�zmod.py�wz# test file for importlib�modT)rr)rrrr	�open�writerr"r#rr)r
r�filer'rrr�test_empty_string_for_dir~sz%FinderTests.test_empty_string_for_dircCs:|j�d|jj|jjf�}d|_|��|�|jd�dS)Nr7�*���)rrrr	�_path_mtime�invalidate_caches�assertEqual)r
rrrr�test_invalidate_caches�s
z"FinderTests.test_invalidate_cachesc	Cs`d}t�|��.}|�|d�}|j|ddd�}|�|�WdQRX|j|ddd�}|�|�dS)Nr9z.rootT)r)rrrrZassertIsNotNoner5)r
r9r$r�foundrrr�test_dir_removal_handling�sz%FinderTests.test_dir_removal_handling�win32z>os.chmod() does not support the needed arguments under Windowscsnt��}t�|j�j��fdd�}|�||�t�|jtjtj	B�|�
|j�}|�|d�}|�||j
�dS)Ncs t�|j��|�ddd�dS)z�Cleanup function for the temporary directory.

            Since we muck with the permissions, we want to set them back to
            their original values to make sure the directory can be properly
            cleaned up.

            N)r�chmodr%�__exit__)�tempdir)�
original_moderr�cleanup�sz3FinderTests.test_no_read_directory.<locals>.cleanup�doesnotexist)�tempfileZTemporaryDirectoryr�statr%�st_modeZ
addCleanuprG�S_IWUSR�S_IXUSRrrrB�	NOT_FOUND)r
rIrKrrDr)rJr�test_no_read_directory�s
z"FinderTests.test_no_read_directoryc	Cs>t���,}|�|j�}|�|d�}|�||j�WdQRXdS)NrL)rMZNamedTemporaryFilerr%rrBrR)r
Zfile_objrrDrrr�test_ignore_file�s
zFinderTests.test_ignore_file)N)�__name__�
__module__�__qualname__�__doc__rrr(r)r*r.r0r4r6r=rCrE�unittestZ
skipUnless�sys�platformrSrTrrrrrs 

		rc@seZdZdZddd�ZdS)�FinderTestsPEP451NFcCs|�|�}|dk	r|jS|S)N)�	find_specr')r
rr%r�specrrrr�s
zFinderTestsPEP451._find)F)rUrVrWrRrrrrrr\�sr\)rc@seZdZdgfZddd�ZdS)�FinderTestsPEP420NFc	Cs:t���(t�dt�|�|�}|r,|dS|SQRXdS)N�ignorer)�warnings�catch_warnings�simplefilter�DeprecationWarning�find_loader)r
rr%rZloader_portionsrrrr�s

zFinderTestsPEP420._find)F)rUrVrWrRrrrrrr_�sr_c@seZdZdZddd�ZdS)�FinderTestsPEP302NFc	Cs*t���t�dt�|�|�SQRXdS)Nr`)rarbrcrd�find_module)r
rr%rrrrr�s
zFinderTestsPEP302._find)F)rUrVrWrRrrrrrrf�srf�__main__)r7rrZimport_importlibrr rrrNrZrMZtest.supportrrYrarr\Z	test_bothZFrozen_FinderTestsPEP451ZSource_FinderTestsPEP451r_ZFrozen_FinderTestsPEP420ZSource_FinderTestsPEP420rfZFrozen_FinderTestsPEP302ZSource_FinderTestsPEP302rU�mainrrrr�<module>s*
.