403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.5
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_cmd_line_script.cpython-36.pyc
3

�w2_�p�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZmZmZmZe
jZdddgZdZefdd	�Zed
fdd�Zd
Zddd�ZGdd�dej�Zdd�Z e!dkr�e �dS)�N)�support)�make_pkg�make_script�make_zip_pkg�make_zip_script�assert_python_ok�assert_python_failure�spawn_python�kill_pythonZtest1Ztest2Ztest3a�# Script may be run with optimisation enabled, so don't rely on assert
# statements being executed
def assertEqual(lhs, rhs):
    if lhs != rhs:
        raise AssertionError('%r != %r' % (lhs, rhs))
def assertIdentical(lhs, rhs):
    if lhs is not rhs:
        raise AssertionError('%r is not %r' % (lhs, rhs))
# Check basic code execution
result = ['Top level assignment']
def f():
    result.append('Lower level reference')
f()
assertEqual(result, ['Top level assignment', 'Lower level reference'])
# Check population of magic variables
assertEqual(__name__, '__main__')
from importlib.machinery import BuiltinImporter
_loader = __loader__ if __loader__ is BuiltinImporter else type(__loader__)
print('__loader__==%a' % _loader)
print('__file__==%a' % __file__)
print('__cached__==%a' % __cached__)
print('__package__==%r' % __package__)
# Check PEP 451 details
import os.path
if __package__ is not None:
    print('__main__ was located through the import system')
    assertIdentical(__spec__.loader, __loader__)
    expected_spec_name = os.path.splitext(os.path.basename(__file__))[0]
    if __package__:
        expected_spec_name = __package__ + "." + expected_spec_name
    assertEqual(__spec__.name, expected_spec_name)
    assertEqual(__spec__.parent, __package__)
    assertIdentical(__spec__.submodule_search_locations, None)
    assertEqual(__spec__.origin, __file__)
    if __spec__.cached is not None:
        assertEqual(__spec__.cached, __cached__)
# Check the sys module
import sys
assertIdentical(globals(), sys.modules[__name__].__dict__)
if __spec__ is not None:
    # XXX: We're not currently making __main__ available under its real name
    pass # assertIdentical(globals(), sys.modules[__spec__.name].__dict__)
from test import test_cmd_line_script
example_args_list = test_cmd_line_script.example_args
assertEqual(sys.argv[1:], example_args_list)
print('sys.argv[0]==%a' % sys.argv[0])
print('sys.path[0]==%a' % sys.path[0])
# Check the working directory
import os
print('cwd==%a' % os.getcwd())
cCst|||�}tj�|S)N)r�	importlib�invalidate_caches)�
script_dir�script_basename�source�	to_return�r�>/opt/alt/python36/lib64/python3.6/test/test_cmd_line_script.py�_make_test_scriptNsr�cCst||||||�}tj�|S)N)rrr)Zzip_dirZzip_basenameZpkg_namerr�depthrrrr�_make_test_zip_pkgSs
rzPimport sys, os.path, runpy
sys.path.insert(0, %s)
runpy._run_module_as_main(%r)
cCs:|dkrd}nt|�}t||f}t|||�}tj�|S)Nzos.path.dirname(__file__))�repr�
launch_sourcerrr)r
rZmodule_name�pathrrrrr�_make_launch_scriptdsrc@s~eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	d[dd
��Z
d\dd�Zd]dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"ej	d>d?��Z#d@dA�Z$dBdC�Z%dDdE�Z&dFdG�Z'dHdI�Z(dJdK�Z)dLdM�Z*dNdO�Z+dPdQ�Z,dRdS�Z-dTdU�Z.dVdW�Z/dXdY�Z0dZS)^�CmdLineTestc	Cstdkr td|�tt|��|j|d�d|}	d|}
d|}d|}d|}
d	tj�}tdkr�td
�t|
�t|�t|�t|�|j|	jd�|�|j|
jd�|�|j|jd�|�|j|jd�|�|j|
jd�|�|j|jd�|�dS)NrzOutput from test script %r:rz__loader__==%az__file__==%az__package__==%rzsys.argv[0]==%azsys.path[0]==%azcwd==%azExpected output:zutf-8)�verbose�printr�assertEqual�os�getcwd�assertIn�encode)�self�script_nameZ	exit_code�data�
expected_file�expected_argv0�expected_path0�expected_package�expected_loaderZprinted_loaderZprinted_fileZprinted_packageZ
printed_argv0Z
printed_path0Zprinted_cwdrrr�
_check_outputos,zCmdLineTest._check_outputc	GsFtj�||ft�}t|ddi�\}	}
}|j||	|
||||||�dS)N�
__isolatedF)rZ!optim_args_from_interpreter_flags�example_argsrr+)r#r$r&r'r(r)r*�cmd_line_switches�run_args�rc�out�errrrr�
_check_script�szCmdLineTest._check_scriptcGsZ||f}t|�\}}}tdkrDtd|�tt|��td|�|j|jd�|�dS)NrzOutput from test script %r:zExpected output: %rzutf-8)rrrrr!r")r#r$Zexpected_msgr.r/r0r1r2rrr�_check_import_error�s
zCmdLineTest._check_import_errorcCs2tdd�\}}}ttjj�jd�}|j||�dS)Nz-czprint(__loader__)zutf-8)rrr�	machinery�BuiltinImporterr"r!)r#r0r1r2�expectedrrr�test_dash_c_loader�szCmdLineTest.test_dash_c_loadercCsNt�}z|jjd�|jj�Wdt|�}Xttjj�j	d�}|j
||�dS)Nsprint(__loader__)
zutf-8)r	�stdin�write�flushr
rrr5r6r"r!)r#�pr1r7rrr�test_stdin_loader�s
zCmdLineTest.test_stdin_loaderFccsv|rtddtjd�}|j}ntddtjd�}|j}z,x |jd�}|dkrJP|j�q6W|VWdt|�|j	�XdS)Nz-ir)�bufsize�stderr�s>>> )
r	�
subprocess�PIPEr?ZSTDOUT�stdout�read�readliner
�close)r#�separate_stderrr<r?r%rrr�interactive_python�s

zCmdLineTest.interactive_pythonc
CsF|j|��2}|jjd�|jj�|jd|jj�j��WdQRXdS)Ns
print('foo')
sfoo)rHr9r:r;rrCrE�strip)r#rGr<rrr�check_repl_stdout_flush�s
z#CmdLineTest.check_repl_stdout_flushc
Csp|j|��\}|jjd�|jj�|r,|jn|j}|jd|j��|jd|j��|jd|j��WdQRXdS)Ns1/0
s
Traceback sFile "<stdin>"sZeroDivisionError)rHr9r:r;r?rCr!rE)r#rGr<r?rrr�check_repl_stderr_flush�s
z#CmdLineTest.check_repl_stderr_flushcCs|j�dS)N)rJ)r#rrr�test_repl_stdout_flush�sz"CmdLineTest.test_repl_stdout_flushcCs|jd�dS)NT)rJ)r#rrr�&test_repl_stdout_flush_separate_stderr�sz2CmdLineTest.test_repl_stdout_flush_separate_stderrcCs|j�dS)N)rK)r#rrr�test_repl_stderr_flush�sz"CmdLineTest.test_repl_stderr_flushcCs|jd�dS)NT)rK)r#rrr�&test_repl_stderr_flush_separate_stderr�sz2CmdLineTest.test_repl_stderr_flush_separate_stderrcCs:tj��(}t|d�}|j||||dtjj�WdQRXdS)N�script)r�temp_dirrr3rr5�SourceFileLoader)r#r
r$rrr�test_basic_script�s



zCmdLineTest.test_basic_scriptcCs\tj��J}t|d�}tj|dd�tj|�tj|�}|j||||dt	j
j�WdQRXdS)NrPT)�doraise)rrQr�
py_compile�compiler�remove�make_legacy_pycr3rr5�SourcelessFileLoader)r#r
r$�pyc_filerrr�test_script_compiled�s



z CmdLineTest.test_script_compiledcCs:tj��(}t|d�}|j||||dtjj�WdQRXdS)N�__main__�)rrQrr3rr5rR)r#r
r$rrr�test_directory�s



zCmdLineTest.test_directorycCs\tj��J}t|d�}tj|dd�tj|�tj|�}|j||||dt	j
j�WdQRXdS)Nr\T)rTr])rrQrrUrVrrWrXr3rr5rY)r#r
r$rZrrr�test_directory_compiled�s




z#CmdLineTest.test_directory_compiledc
Cs,tj��}d|}|j||�WdQRXdS)Nz"can't find '__main__' module in %r)rrQr4)r#r
�msgrrr�test_directory_errors
z CmdLineTest.test_directory_errorcCsHtj��6}t|d�}t|d|�\}}|j||||dtj�WdQRXdS)Nr\�test_zipr])rrQrrr3�	zipimport�zipimporter)r#r
r$�zip_name�run_namerrr�test_zipfiles


zCmdLineTest.test_zipfilecCsVtj��D}t|d�}tj|dd�}t|d|�\}}|j||||dtj�WdQRXdS)Nr\T)rTrbr])	rrQrrUrVrr3rcrd)r#r
r$�
compiled_namererfrrr�test_zipfile_compileds

z!CmdLineTest.test_zipfile_compiledcCsFtj��4}t|d�}t|d|�\}}d|}|j||�WdQRXdS)NZnot_mainrbz"can't find '__main__' module in %r)rrQrrr4)r#r
r$rerfr`rrr�test_zipfile_errors


zCmdLineTest.test_zipfile_errorcCs\tj��J}tjj|d�}t|�t|d�}t|dd�}|j||||dt	j
j�WdQRXdS)N�test_pkgrP�launchztest_pkg.script)rrQrr�joinrrrr3rr5rR)r#r
�pkg_dirr$�launch_namerrr�test_module_in_packages


z"CmdLineTest.test_module_in_packagecCsNtj��<}t|ddd�\}}t|dd|�}|j||||dtj�WdQRXdS)NrbrkrPrlztest_pkg.script)rrQrrr3rcrd)r#r
rerfrorrr�!test_module_in_package_in_zipfile's


z-CmdLineTest.test_module_in_package_in_zipfilecCsRtj��@}t|ddddd�\}}t|dd|�}|j||||dtj�WdQRXdS)	NrbrkrP�)rrlztest_pkg.test_pkg.scriptztest_pkg.test_pkg)rrQrrr3rcrd)r#r
rerfrorrr�$test_module_in_subpackage_in_zipfile.s

z0CmdLineTest.test_module_in_subpackage_in_zipfilecCs\tj��J}tjj|d�}t|�t|d�}t|dd�}|j||||dt	j
j�WdQRXdS)Nrkr\rl)rrQrrrmrrrr3rr5rR)r#r
rnr$rorrr�test_package6s

zCmdLineTest.test_packagecCs~tj��l}tjj|d�}t|�t|d�}tj|dd�}tj	|�tj
|�}t|dd�}|j||||dt
jj�WdQRXdS)Nrkr\T)rTrl)rrQrrrmrrrUrVrWrXrr3rr5rY)r#r
rnr$rhrZrorrr�test_package_compiled@s



z!CmdLineTest.test_package_compiledcCsJtj��8}tjj|d�}t|�d}t|dd�}|j||�WdQRXdS)Nrkz7'test_pkg' is a package and cannot be directly executedrl)rrQrrrmrrr4)r#r
rnr`rorrr�test_package_errorMs
zCmdLineTest.test_package_errorcCs`tj��N}tjj|d�}t|�tjj|d�}t|�d}t|dd�}|j||�WdQRXdS)Nrkr\z^Cannot use package as __main__ module; 'test_pkg' is a package and cannot be directly executedrl)rrQrrrmrrr4)r#r
rnZmain_dirr`rorrr�test_package_recursionVs
z"CmdLineTest.test_package_recursioncCs�tj���}tj|d���tjj|d�}t|d�t|d�}td
t	�ddi�\}}}t
d	krftt|��d
d}|j
|jd�|�|j|||||ddtjj�WdQRXWdQRXdS)N)rrkz1import sys; print('init_argv0==%r' % sys.argv[0])rP�-m�test_pkg.scriptr,Frzinit_argv0==%rzutf-8r])rxry)rrQ�
change_cwdrrrmrrrr-rrrr!r"r+rr5rR)r#r
rnr$r0r1r2r7rrr�test_issue8202bs



zCmdLineTest.test_issue8202cCs�tj���}tj|d��htdd��R}|jd�tdddd�\}}}tdkrVtt|��d	d
}|j	|j
d�|�WdQRXWdQRXWdQRXdS)N)rz-c�wr%z2import sys; print("sys.path[0]==%r" % sys.path[0])F)r,rzsys.path[0]==%rr]zutf-8)rrQrz�openr:rrrrr!r")r#r
�fr0r1r2r7rrr�"test_issue8202_dash_c_file_ignoredss

z.CmdLineTest.test_issue8202_dash_c_file_ignoredcCs�tj��|}t|d�}tj|d��Ztdd��D}|jd�td	t�ddi�\}}}|j|||||ddt	j
j�WdQRXWdQRXWdQRXdS)
N�other)r�-mr|r%r,Fr])r�r�)rrQrrzr}r:rr-r+rr5rR)r#r
r$r~r0r1r2rrr�"test_issue8202_dash_m_file_ignored�s




z.CmdLineTest.test_issue8202_dash_m_file_ignoredcgsRtj��@}tj|d��(tjj|d�}t|f|��|VWdQRXWdQRXdS)N)rrk)rrQrzrrrmr)r#�argsr
rnrrr�setup_test_pkg�s

zCmdLineTest.setup_test_pkgcGs<td|�ddi�\}}}tdkr,tt|��|j|d�|S)N�-mr,Fr)r�)rrrrr)r#r�r0r1r2rrr�check_dash_m_failure�s
z CmdLineTest.check_dash_m_failurecCs>|j��,}t|dd�}|jdt��}|jd|�WdQRXdS)Nr�z+if __name__ == '__main__': raise ValueError�test_pkg.others
ValueError)r�)r�rr�r-r!)r#rnr$r2rrr�test_dash_m_error_code_is_one�s

z)CmdLineTest.test_dash_m_error_code_is_onecCsdd}xZ|D]R\}}|j|��:td|�\}}}|j|d�|j||�|jd|�WdQRXq
WdS)N�builtins�No code object available�
builtins.x�8Error while finding module specification.*AttributeError�builtins.x.y�]Error while finding module specification.*ModuleNotFoundError.*No module named.*not a package�os.path�loader.*cannot handler�=No module named.*is a package and cannot be directly executed�importlib.nonexistant�No module named�	.unittest�#Relative module names not supportedz-mrs	Traceback�r�r��r�r��r�r��r�r��rr��r�r��r�r�)r�r�r�r�r�r�r�)�subTestrr�assertRegex�assertNotIn)r#Ztests�nameZregexr0�_r2rrr�test_dash_m_errors�szCmdLineTest.test_dash_m_errorscCs~tj��l}tj|d��Ttjd�tdd��WdQRX|jd�}|j|d�|jd|�|jd|�WdQRXWdQRXdS)N)rrkztest_pkg/__init__.pyc�wbsGError while finding module specification.*ImportError.*bad magic numbersis a packages	Traceback)	rrQrzr�mkdirr}r�r�r�)r#r
r2rrr�test_dash_m_bad_pyc�s



zCmdLineTest.test_dash_m_bad_pyccCs�ttttf}x||D]t}|j}dj|�}|j|��P|j|��:}|jd�}|j	|j
d�|�|j	d|�|j	d|�WdQRXWdQRXqWdS)Nz%raise {0}('Exception in __init__.py')rk�asciisException in __init__.pys	Traceback)�ImportError�AttributeError�	TypeError�
ValueError�__name__�formatr�r�r�r!r")r#�
exceptionsZ	exceptionZinitrnr2rrr�test_dash_m_init_traceback�s


z&CmdLineTest.test_dash_m_init_tracebackcCsV|j��D}d}t|d|�|jd�}|jd|�|jd|�|jd|�WdQRXdS)Nz1raise ImportError('Exception in __main__ module')r\rksImportErrorsException in __main__ modules	Traceback)r�rr�r!)r#rn�mainr2rrr�test_dash_m_main_traceback�s

z&CmdLineTest.test_dash_m_main_tracebackcCs�tjd�}tj��|}t|d|�}t|�\}}}|jd�jd�}|jt	|�d�|j
|djd��|j
|djd	��|j
|d
jd��WdQRXdS)Nz|            try:
                raise ValueError
            except:
                raise NameError from None
            rPr��
r@rZ	Tracebackrz  File ��	NameError)�textwrap�dedentrrQrr�decode�splitr�lenZ
assertTrue�
startswith)r#rPr
r$�exitcoderCr?�textrrr�test_pep_409_verbiage�s
z!CmdLineTest.test_pep_409_verbiagecCs�tjrtjdkrtjtj�}ntjr,tj}n
|jd�d}ttj	||�}|j
tj|�t|�\}}}|j
t|�|j�jd�d||f�|j
d|�dS)	N�win32�darwinzneed support.TESTFN_NONASCIIzprint(ascii(__file__))
r�zstdout=%r stderr=%rr)r�r�)rZTESTFN_UNDECODABLE�sys�platformr�fsdecodeZTESTFN_NONASCIIZskipTestr�curdirZ
addCleanup�unlinkrrr��rstripr�)r#r�rr$r0rCr?rrr�test_non_ascii�s

zCmdLineTest.test_non_asciicCsRtjd�}tj��6}t|d|�}t|�\}}}|jd�}|j|d�WdQRXdS)Nz�            import sys
            error = None
            try:
                raise ValueError('some text')
            except ValueError as err:
                error = err

            if error:
                sys.exit(error)
            rPr�z	some text)r�r�rrQrrr�r)r#rPr
r$r�rCr?r�rrr�)test_issue20500_exit_with_exception_value
s


z5CmdLineTest.test_issue20500_exit_with_exception_valuecCsXd}tj��B}t|d|�}t|�\}}}tjtj|�d�j�}|jd|�WdQRXdS)Nz
1 + 1 = 2
rPr�z
    1 + 1 = 2
    ^)	rrQrr�io�
TextIOWrapper�BytesIOrDr!)r#rPr
r$r�rCr?r�rrr�*test_syntaxerror_unindented_caret_positions
z6CmdLineTest.test_syntaxerror_unindented_caret_positioncCs�tjd�}tj���}t|d|�}t|�\}}}tjtj|�d�j	�}|j
d|�d}t|d|�}t|�\}}}tjtj|�d�j	�}|jd|�|j
d|�WdQRXdS)Nz;            if True:
                1 + 1 = 2
            rPr�z
    1 + 1 = 2
    ^zif True:
    1 + 1 = 2
�)r�r�rrQrrr�r�r�rDr!r�)r#rPr
r$r�rCr?r�rrr�(test_syntaxerror_indented_caret_position(s
z4CmdLineTest.test_syntaxerror_indented_caret_positionc	Cs�tjd�}d|_tj���}tj���}t|d|�}td||d�}t|�j�j	�}|j
|d|�|j||�td||d�}t|�j�j	�}|j
||�td||d�}t|�j�j	�}|j
|||�WdQRXWdQRXdS)Nzc            import sys
            for entry in sys.path:
                print(entry)
            r\z-Es)�cwdrz-I)r�r��maxDiffrrQrr	r
r��
splitlinesrr�)	r#rP�work_dirr
r$r<Zout_by_nameZ
out_by_dirZout_by_dir_isolatedrrr�-test_consistent_sys_path_for_direct_execution?sz9CmdLineTest.test_consistent_sys_path_for_direct_executioncCs�tjd�}d|_tj���}tjj|d�}tj|�t	|d|�}t
dd|d�}t|�j�j
�}|j|dd�|j||�t
dd|d�}t|�j�j
�}|j||�td	d|d�\}}	}
|
j�j
�}|jd
|d�WdQRXdS)
Nzc            import sys
            for entry in sys.path:
                print(entry)
            Z
script_pkgr\z-smzscript_pkg.__main__)r�rr]z-ImzNo module named script_pkgr���)r�r�r�rrQrrrmr�rr	r
r�r�rr�rr!)r#rPr�r
r$r<Z
out_by_moduleZout_by_packager�rCr?Ztraceback_linesrrr�-test_consistent_sys_path_for_module_execution^s$

z9CmdLineTest.test_consistent_sys_path_for_module_executionN)F)F)F)1r��
__module__�__qualname__r+r3r4r8r=�
contextlib�contextmanagerrHrJrKrLrMrNrOrSr[r^r_rargrirjrprqrsrtrurvrwr{rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrnsZ



	




	

	rcCstjt�tj�dS)N)rZrun_unittestrZ
reap_childrenrrrr�	test_main�s
r�r\)N)"r�r�importlib.machineryrcZunittestr�rZos.pathrUrAr�r�ZtestrZtest.support.script_helperrrrrrrr	r
rr-Ztest_sourcerrrrZTestCaserr�r�rrrr�<module>s8(
5



Youez - 2016 - github.com/yon3zu
LinuXploit