Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_cmd_line_script.cpython-310.pyc
o

�9j���@s
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZmZmZmZmZmZmZmZe
jZgd�ZdZefdd	�Zed
fdd�ZGd
d�dej�Z dd�Z!e"dkr�e�#�dSdS)�N)�support)�
import_helper)�	os_helper)�make_pkg�make_script�make_zip_pkg�make_zip_script�assert_python_ok�assert_python_failure�spawn_python�kill_python)�test1�test2�test3a�# 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|||�}t��|S�N)r�	importlib�invalidate_caches)�
script_dir�script_basename�source�	to_return�r�0/usr/lib/python3.10/test/test_cmd_line_script.py�_make_test_scriptPsr�cCst||||||�}t��|Sr)rrr)�zip_dir�zip_basename�pkg_namerr�depthrrrr�_make_test_zip_pkgUs

�rc@s�eZdZ	dpdd�Zdd�dd�Zdd�dd�Zd	d
�Zdd�Zej	dqdd��Z
dqdd�Zdqdd�Zdd�Z
dd�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�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&ej	dHdI��Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1d^d_�Z2d`da�Z3dbdc�Z4ddde�Z5dfdg�Z6dhdi�Z7djdk�Z8e9�:e;j<�=dl�dm�dndo��Z>dS)r�CmdLineTestNc
Cstdkrtd|�tt|��|�|d�d|}
d|}d|}d|}
d|}|	dur2t��}	d	|	}tdkrNtd
�t|�t|�t|
�t|�|�|
�d�|�|�|�d�|�|�|�d�|�|�|
�d�|�|�|�d�|�|�|�d�|�dS)NrzOutput from test script %r:rz__loader__==%az__file__==%az__package__==%rzsys.argv[0]==%azsys.path[0]==%azcwd==%azExpected output:�utf-8)�verbose�print�repr�assertEqual�os�getcwd�assertIn�encode)�self�script_name�	exit_code�data�
expected_file�expected_argv0�expected_path0�expected_package�expected_loader�expected_cwd�printed_loader�printed_file�printed_package�
printed_argv0�
printed_path0�printed_cwdrrr�
_check_output]s0zCmdLineTest._check_output��cwdcOsdt|t�r|g}gt���|�|�t�}
t|
d|d�|	��\}}}
|�||||
||||||�	dS)NF��
__isolated�__cwd)�
isinstance�strr�!optim_args_from_interpreter_flags�example_argsr	r:)r*�script_exec_argsr.r/r0r1r2r<�cmd_line_switches�env_vars�run_args�rc�out�errrrr�
_check_scriptzs$

������zCmdLineTest._check_scriptc
Os�t|t�r	|f}nt|�}||}t|d|d�|��\}}}	tdkr6td|����tt|	��td|�|�|�d�|	�dS)NFr=rzOutput from test script zExpected output: %rr!)	r@rA�tupler
r"r#r$r(r))
r*rD�expected_msgr<rErFrGrHrIrJrrr�_check_import_error�s
��zCmdLineTest._check_import_errorcCs2tdd�\}}}ttjj��d�}|�||�dS)N�-czprint(__loader__)r!)r	r$r�	machinery�BuiltinImporterr)r()r*rHrIrJ�expectedrrr�test_dash_c_loader�szCmdLineTest.test_dash_c_loadercCsVt�}z|j�d�|j��Wt|�}nt|�}wttjj��	d�}|�
||�dS)Nsprint(__loader__)
r!)r�stdin�write�flushrr$rrPrQr)r()r*�prIrRrrr�test_stdin_loader�szCmdLineTest.test_stdin_loaderFccs��|rtdtjd�}|j}n
tdtjd�}|j}z	|�d�}|dkr$n|��q|VWt|�|�	�dSt|�|�	�w)Nz-i)�stderrT�s>>> )
r�
subprocess�PIPErY�STDOUT�stdout�read�readliner�close)r*�separate_stderrrWrYr-rrr�interactive_python�s$�
��
zCmdLineTest.interactive_pythoncCs\|�|��}|j�d�|j��|�d|j�����Wd�dS1s'wYdS)Ns
print('foo')
sfoo)rcrTrUrVr%r^r`�strip)r*rbrWrrr�check_repl_stdout_flush�s

"�z#CmdLineTest.check_repl_stdout_flushcCs�|�|��4}|j�d�|j��|r|jn|j}|�d|���|�d|���|�d|���Wd�dS1s<wYdS)Ns1/0
s
Traceback sFile "<stdin>"sZeroDivisionError)rcrTrUrVrYr^r(r`)r*rbrWrYrrr�check_repl_stderr_flush�s
"�z#CmdLineTest.check_repl_stderr_flushcC�|��dSr�re�r*rrr�test_repl_stdout_flush��z"CmdLineTest.test_repl_stdout_flushcC�|�d�dS�NTrhrirrr�&test_repl_stdout_flush_separate_stderr��z2CmdLineTest.test_repl_stdout_flush_separate_stderrcCrgr�rfrirrr�test_repl_stderr_flush�rkz"CmdLineTest.test_repl_stderr_flushcCrlrmrprirrr�&test_repl_stderr_flush_separate_stderr�roz2CmdLineTest.test_repl_stderr_flush_separate_stderrc
CsTt���}t|d�}|j||||dtjj|d�Wd�dS1s#wYdS)N�script)r3�r�temp_dirrrKrrP�SourceFileLoader�r*rr+rrr�test_basic_script�s


�"�zCmdLineTest.test_basic_scriptc	Cspt���*}|�tj�|�|�t|d�}tj�|�}|�||||dt	j
j�Wd�dS1s1wYdS)Nrs)r�temp_cwd�
assertTruer&�path�isabsr�basenamerKrrPrv)r*rr+�
relative_namerrr�test_script_abspath�s


�"�zCmdLineTest.test_script_abspathc	Csrt���+}t|d�}tj|dd�t�|�t�|�}|�	||||dt
jj�Wd�dS1s2wYdS)NrsT��doraise�
rrur�
py_compile�compiler&�remover�make_legacy_pycrKrrP�SourcelessFileLoader�r*rr+�pyc_filerrr�test_script_compiled�s



�"�z CmdLineTest.test_script_compiledc	CsPt���}t|d�}|�||||dtjj�Wd�dS1s!wYdS)N�__main__�rtrwrrr�test_directory�s


�"�zCmdLineTest.test_directoryc	Csrt���+}t|d�}tj|dd�t�|�t�|�}|�	||||dt
jj�Wd�dS1s2wYdS)Nr�Tr�r�r�r�rrr�test_directory_compiled�s




�"�z#CmdLineTest.test_directory_compiledcCsBt���}d|}|�||�Wd�dS1swYdS)N�"can't find '__main__' module in %r)rrurN)r*r�msgrrr�test_directory_error	s
"�z CmdLineTest.test_directory_errorc	Cs^t���!}t|d�}t|d|�\}}|�||||dtj�Wd�dS1s(wYdS)Nr��test_zipr�)rrurrrK�	zipimport�zipimporter)r*rr+�zip_name�run_namerrr�test_zipfiles

�"�zCmdLineTest.test_zipfilec	C�rt���+}t|d�}tj|dtjjd�}t|d|�\}}|�||||dt	j
�Wd�dS1s2wYdS�Nr�T)r��invalidation_moder�r�)rrurr�r��PycInvalidationMode�	TIMESTAMPrrKr�r��r*rr+�
compiled_namer�r�rrr�test_zipfile_compiled_timestamp�

��"�z+CmdLineTest.test_zipfile_compiled_timestampc	Cr�r�)rrurr�r�r��CHECKED_HASHrrKr�r�r�rrr�"test_zipfile_compiled_checked_hashr�z.CmdLineTest.test_zipfile_compiled_checked_hashc	Cr�r�)rrurr�r�r��UNCHECKED_HASHrrKr�r�r�rrr�$test_zipfile_compiled_unchecked_hash)r�z0CmdLineTest.test_zipfile_compiled_unchecked_hashcCs\t��� }t|d�}t|d|�\}}d|}|�||�Wd�dS1s'wYdS)N�not_mainr�r�)rrurrrN)r*rr+r�r�r�rrr�test_zipfile_error3s

"�zCmdLineTest.test_zipfile_errorc
Csnt���)}tj�|d�}t|�t|d�}|jddg|||dtj	j
|d�Wd�dS1s0wYdS)N�test_pkgrs�-m�test_pkg.scriptr;�rrur&r{�joinrrrKrrPrv�r*r�pkg_dirr+rrr�test_module_in_package:s

�"�z"CmdLineTest.test_module_in_packagecCs`t���"}t|ddd�\}}|jddg|||dtj||d�Wd�dS1s)wYdS)Nr�r�rsr�r���
PYTHONPATHr<�rrurrKr�r��r*rr�r�rrr�!test_module_in_package_in_zipfileDs
�"�z-CmdLineTest.test_module_in_package_in_zipfilecCsdt���$}t|ddddd�\}}|jddg|||dtj||d	�Wd�dS1s+wYdS)
Nr�r�rs�)rr�ztest_pkg.test_pkg.scriptztest_pkg.test_pkgr�r�r�rrr�$test_module_in_subpackage_in_zipfileKs
�"�z0CmdLineTest.test_module_in_subpackage_in_zipfilec
Csnt���)}tj�|d�}t|�t|d�}|jddg|||dtj	j
|d�Wd�dS1s0wYdS)Nr�r�r�r;r�r�rrr�test_packageSs

�"�zCmdLineTest.test_packagec
Cs�t���:}tj�|d�}t|�t|d�}tj|dd�}t�	|�t
�|�}|jddg|||dt
jj|d�Wd�dS1sAwYdS)Nr�r�Tr�r�r;)rrur&r{r�rrr�r�r�rr�rKrrPr�)r*rr�r+r�r�rrr�test_package_compiled]s



�"�z!CmdLineTest.test_package_compiledcCs\t��� }tj�|d�}t|�d}|jddg||d�Wd�dS1s'wYdS)Nr�z7'test_pkg' is a package and cannot be directly executedr�r;�rrur&r{r�rrN)r*rr�r�rrr�test_package_errorjs
"�zCmdLineTest.test_package_errorcCsrt���+}tj�|d�}t|�tj�|d�}t|�d}|jddg||d�Wd�dS1s2wYdS)Nr�r�z^Cannot use package as __main__ module; 'test_pkg' is a package and cannot be directly executedr�r;r�)r*rr��main_dirr�rrr�test_package_recursionrs
"�z"CmdLineTest.test_package_recursioncCs�t���l}tj|d��Mtj�|d�}t|d�t|d�}tddgt	�Rddi�\}}}t
d	kr6tt|��d
d}|�
|�d�|�|�||||||dtjj�Wd�n1s[wYWd�dSWd�dS1sswYdS)N�r{r�z1import sys; print('init_argv0==%r' % sys.argv[0])rsr�r�r>Frzinit_argv0==%rr!)rru�
change_cwdr&r{r�rrr	rCr"r#r$r(r)r:rrPrv)r*rr�r+rHrIrJrRrrr�test_issue8202}s$



���"�zCmdLineTest.test_issue8202c
Cs�t���d}tj|d��Etdddd��.}|�d�tdddd	�\}}}td
kr-tt|��dd}|�	|�
d�|�Wd�n1sDwYWd�n1sSwYWd�dSWd�dS1skwYdS)
Nr�rO�wr!��encodingr-z2import sys; print("sys.path[0]==%r" % sys.path[0])F)r>rzsys.path[0]==%rr�)rrur��openrUr	r"r#r$r(r))r*r�frHrIrJrRrrr�"test_issue8202_dash_c_file_ignored�s$

�����"�z.CmdLineTest.test_issue8202_dash_c_file_ignoredc
Cs�t���e}t|d�}tj|d��Atdddd��*}|�d�tddgt�Rdd	i�\}}}|�||||||d
t	j
j�Wd�n1sEwYWd�n1sTwYWd�dSWd�dS1slwYdS)N�otherr�r�r�r!r�r-r>Fr�)rrurr�r�rUr	rCr:rrPrv)r*rr+r�rHrIrJrrr�"test_issue8202_dash_m_file_ignored�s$


�
�����"�z.CmdLineTest.test_issue8202_dash_m_file_ignoredc	Cs�t���l}tj�|d�}t|dddd��#}|�d�|�d�td�D]}|�d	�q#|�d�Wd�n1s:wYtj|d
��t	|�\}}}Wd�n1sWwY|�
d|�|�
d|�Wd�dS1sswYdS)Nz
issue20884.pyr��latin1�
)r��newlinez#coding: iso-8859-1
z"""
�zQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
r��)rrur&r{r�r�rU�ranger�r	r%)r*rr+r��_rHrIrJrrr�test_issue20884�s


��"�zCmdLineTest.test_issue20884c	gs��t���9}tj|d��tj�|d�}t|g|�R�|VWd�n1s)wYWd�dSWd�dS1sAwYdS)Nr�r�)rrur�r&r{r�r)r*�argsrr�rrr�setup_test_pkg�s�

�P�zCmdLineTest.setup_test_pkgcGs@tdg|�Rddi�\}}}tdkrtt|��|�|d�|S)Nr�r>Fr)r
r"r#r$r%)r*r�rHrIrJrrr�check_dash_m_failure�s
z CmdLineTest.check_dash_m_failurecCsX|���}t|dd�}|jdgt�R�}|�d|�Wd�dS1s%wYdS)Nr�z+if __name__ == '__main__': raise ValueErrorztest_pkg.others
ValueError)r�rr�rCr()r*r�r+rJrrr�test_dash_m_error_code_is_one�s
�"�z)CmdLineTest.test_dash_m_error_code_is_onec	Cstd}|D]3\}}|�|��"td|�\}}}|�|d�|�||�|�d|�Wd�n1s2wYqdS)N))�builtinssNo code object available)z
builtins.xs=Error while finding module specification.*ModuleNotFoundError)zbuiltins.x.ys]Error while finding module specification.*ModuleNotFoundError.*No module named.*not a package)zos.pathsloader.*cannot handle)rs=No module named.*is a package and cannot be directly executed)zimportlib.nonexistentsNo module named)z	.unittests#Relative module names not supportedr�r�	Traceback)�subTestr
r%�assertRegex�assertNotIn)r*�tests�name�regexrHr�rJrrr�test_dash_m_errors�s���zCmdLineTest.test_dash_m_errorsc
Cs�t���X}tj|d��9t�d�tdd��Wd�n1s!wY|�d�}|�|d�|�d|�|�d|�Wd�n1sGwYWd�dSWd�dS1s_wYdS)Nr�r�ztest_pkg/__init__.pyc�wbsGError while finding module specification.*ImportError.*bad magic numbersis a packager�)	rrur�r&�mkdirr�r�r�r��r*rrJrrr�test_dash_m_bad_pyc�s

�
�
�P�zCmdLineTest.test_dash_m_bad_pycc
Cs�t���G}tj|d��(tdd��Wd�n1swY|�d�}|�d|�Wd�n1s6wYWd�dSWd�dS1sNwYdS)Nr�z
asyncio.pyr�s>Try using 'asyncio' instead of 'asyncio.py' as the module name)rrur�r�r�r(r�rrr�*test_hint_when_triying_to_import_a_py_file�s

��
�P�z6CmdLineTest.test_hint_when_triying_to_import_a_py_filec
Cs�ttttf}|D]N}|j}d�|�}|�|��7|�|��"}|�d�}|�	|�
d�|�|�	d|�|�	d|�Wd�n1sBwYWd�n1sQwYqdS)Nz%raise {0}('Exception in __init__.py')r��asciisException in __init__.pyr�)�ImportError�AttributeError�	TypeError�
ValueError�__name__�formatr�r�r�r(r))r*�
exceptions�	exception�initr�rJrrr�test_dash_m_init_tracebacks"
�
����z&CmdLineTest.test_dash_m_init_tracebackcCsl|���(}d}t|d|�|�d�}|�d|�|�d|�|�d|�Wd�dS1s/wYdS)Nz1raise ImportError('Exception in __main__ module')r�r�sImportErrorsException in __main__ moduler�)r�rr�r()r*r��mainrJrrr�test_dash_m_main_tracebacks

"�z&CmdLineTest.test_dash_m_main_tracebackcCs�t�d�}t���D}t|d|�}t|�\}}}|�d��d�}|�t	|�d�|�
|d�d��|�
|d�d	��|�
|d
�d��Wd�dS1sPwYdS)Nz|            try:
                raise ValueError
            except:
                raise NameError from None
            rsr�r��r�	Tracebackrz  File ��	NameError)�textwrap�dedentrrurr
�decode�splitr%�lenrz�
startswith�r*rsrr+�exitcoder^rY�textrrr�test_pep_409_verbiages

"�z!CmdLineTest.test_pep_409_verbiagecCs�tjrtjdvrt�tj�}ntjrtj}n|�d�d}tt�	�||�}|�
tj|�t|�\}}}|�
t|�|���d�d||f�|�
d|�dS)N)�win32�darwinzneed os_helper.TESTFN_NONASCIIzprint(ascii(__file__))
r�zstdout=%r stderr=%rr)r�TESTFN_UNDECODABLE�sys�platformr&�fsdecode�TESTFN_NONASCII�skipTestrr'�
addCleanup�unlinkr	r%r��rstripr�)r*r�rr+rHr^rYrrr�test_non_ascii,s 


�zCmdLineTest.test_non_asciicCslt�d�}t���#}t|d|�}t|�\}}}|�d�}|�|��d�Wd�dS1s/wYdS)Nz�            import sys
            error = None
            try:
                raise ValueError('some text')
            except ValueError as err:
                error = err

            if error:
                sys.exit(error)
            rsr�z	some text)	r�r�rrurr
r�r%rr�rrr�)test_issue20500_exit_with_exception_valueCs


"�z5CmdLineTest.test_issue20500_exit_with_exception_valuecCsnd}t���'}t|d|�}t|�\}}}t�t�|�d���}|�d|�Wd�dS1s0wYdS)Nz
1 + 1 = 2
rsr�z
    ^^^^^
)	rrurr
�io�
TextIOWrapper�BytesIOr_r(r�rrr�*test_syntaxerror_unindented_caret_positionUs
"�z6CmdLineTest.test_syntaxerror_unindented_caret_positioncCs�t�d�}t���M}t|d|�}t|�\}}}t�t�|�d��	�}|�
d|�d}t|d|�}t|�\}}}t�t�|�d��	�}|�d|�|�
d|�Wd�dS1sYwYdS)Nz;            if True:
                1 + 1 = 2
            rsr�z
    1 + 1 = 2
    ^^^^^
zif True:
    1 + 1 = 2
�)r�r�rrurr
r	r
rr_r(r�r�rrr�(test_syntaxerror_indented_caret_position^s

�"�z4CmdLineTest.test_syntaxerror_indented_caret_positioncCshd}t���$}t|d|�}t|�\}}}|�|��dd�gd��Wd�dS1s-wYdS)Nzfoo = f"""{}
foo"""
rs���)s
    foo"""s          ^s3SyntaxError: f-string: empty expression not allowed�rrurr
r%�
splitlines�r*rsrr+r�r^rYrrr�#test_syntaxerror_multi_line_fstringus
�"�z/CmdLineTest.test_syntaxerror_multi_line_fstringcCsjd}t���%}t|d|�}td|�\}}}|�|��dd�gd��Wd�dS1s.wYdS)Nzfoo = """\q"""
rsz-Werrorr)s    foo = """\q"""s          ^^^^^^^^s)SyntaxError: invalid escape sequence '\q'rrrrr�3test_syntaxerror_invalid_escape_sequence_multi_line�s

��"�z?CmdLineTest.test_syntaxerror_invalid_escape_sequence_multi_linec		Cst�d�}d|_t���s}t���V}t|d|�}td||d�}t|����	�}|�
|d|�|�||�td||d�}t|����	�}|�
||�td||d�}t|����	�}|�
|||�Wd�n1sjwYWd�dSWd�dS1s�wYdS)N�c            import sys
            for entry in sys.path:
                print(entry)
            r�z-Esr;rz-I)r�r��maxDiffrrurrrr�rr%r�)	r*rs�work_dirrr+rW�out_by_name�
out_by_dir�out_by_dir_isolatedrrr�-test_consistent_sys_path_for_direct_execution�s
P�z9CmdLineTest.test_consistent_sys_path_for_direct_executioncCs�t�d�}d|_t���e}tj�|d�}t�|�t	|d|�}t
dd|d�}t|����
�}|�|d|�|�||�t
dd|d�}t|����
�}|�||�tdd|d�\}}	}
|
���
�}|�d	|d
�Wd�dS1stwYdS)Nr�
script_pkgr�z-smzscript_pkg.__main__r;rz-ImzNo module named script_pkg���)r�r�rrrur&r{r�r�rrrr�rr%r�r
r()r*rsrrr+rW�
out_by_module�out_by_packager�r^rY�traceback_linesrrr�-test_consistent_sys_path_for_module_execution�s&


�"�z9CmdLineTest.test_consistent_sys_path_for_module_executioncCsTd}|�tj�|��t|dtjtjd�}|��\}}|�d|�|�	|j
d�dS)Nznonexistingscript.pyT)r�r^rYz: can't open file r)�assertFalser&r{�existsrr[r\�communicater(�assertNotEqual�
returncode)r*rs�procrIrJrrr�test_nonexisting_script�s�z#CmdLineTest.test_nonexisting_scriptz	/dev/fd/0zrequires /dev/fd platformc
Cs�d}t���J}t|d|�}t|d��&}td|����dddd|��fd	�}|��\}}|�|d
�Wd�n1s;wYWd�dSWd�dS1sSwYdS)Nz print("12345678912345678912345")z	script.py�rz/dev/fd/Frrr�)�	close_fds�pass_fdss12345678912345678912345
)rrurr�r�filenor$r%)r*rsrr+�fprWrIrJrrr�test_script_as_dev_fd�s
$��"�z!CmdLineTest.test_script_as_dev_fdr)F)?r��
__module__�__qualname__r:rKrNrSrX�
contextlib�contextmanagerrcrerfrjrnrqrrrxrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr!r(�unittest�
skipUnlessr&r{r#r.rrrrr \sx
� ��


	











	%r cCst��dSr)r�
reap_childrenrrrr�tearDownModule�rkr6r�)$r1r�importlib.machineryr�r3r�r&�os.pathr�r[r	r��testr�test.supportrr�test.support.script_helperrrrrr	r
rrr"rC�test_sourcerr�TestCaser r6r�r�rrrr�<module>s@(5
��

Youez - 2016 - github.com/yon3zu
LinuXploit