Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_cmd_line_script.cpython-312.pyc

�

'Μg����H�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZmZmZmZmZmZmZmZe
j4Zgd�ZdZefd�Zed	fd
�ZGd�dej>�Z d
�Z!e"dk(rejF�yy)�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())
c�H�t|||�}tj�|S�N)r�	importlib�invalidate_caches)�
script_dir�script_basename�source�	to_returns    �6/usr/local/lib/python3.12/test/test_cmd_line_script.py�_make_test_scriptrPs"���J���@�I�
���!����c�N�t||||||�}tj�|Sr)rrr)�zip_dir�zip_basename�pkg_namerr�depthrs       r�_make_test_zip_pkgr"Us+���W�l�H�o�#�U�,�I�
���!��rc���eZdZ	d@d�Zdd�d�Zdd�d�Zd�Zd�ZejdAd��Z
dAd	�ZdAd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&ejd%��Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:e;jxe=j|jd9�d:�e;j�eAj�j�d;�xr9e=j�d<�j�e=j�d=�j�k(d>�d?���ZFy)B�CmdLineTestNc
�&�tdkDr"td|z�tt|��|j|d�d|z}
d|z}d|z}d|z}
d|z}|	�t	j
�}	d	|	z}tdkDr7td
�t|�t|�t|
�t|�|j
|
jd�|�|j
|jd�|�|j
|jd�|�|j
|
jd�|�tjjs!|j
|jd�|�|j
|jd�|�y)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�sys�flags�	safe_path)�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_cwds                r�
_check_outputzCmdLineTest._check_output]sV���Q�;��/�+�=�>��$�t�*������A�&�)�O�;��%�
�5��+�.>�>��)�N�:�
�)�N�:�
����9�9�;�L��,�.���Q�;��$�%��,���/�"��-� ��+���
�
�n�+�+�G�4�d�;��
�
�l�)�)�'�2�D�9��
�
�o�,�,�W�5�t�<��
�
�m�*�*�7�3�T�:��y�y�"�"��M�M�-�.�.�w�7��>��
�
�k�(�(��1�4�8r��cwdc���t|t�r|g}gtj��|�|�t�}
t|
d|d�|	��\}}}
|j
||||
z||||||�	y)NF��
__isolated�__cwd)�
isinstance�strr�!optim_args_from_interpreter_flags�example_argsr
rB)r2�script_exec_argsr6r7r8r9r:rD�cmd_line_switches�env_vars�run_args�rc�out�errs              r�
_check_scriptzCmdLineTest._check_script|s����&��,� 0�1��J�W�>�>�@�J�&�J�)9�J�<H�J��'�
�%�s�
�6>�
���C��	
���+�R��s��M�)�>�+�_�c�	Crc�&�t|t�r|f}nt|�}||z}t|d|d�|��\}}}	tdkDr1td|����tt
|	��td|z�|j|jd�|	�y)NFrFrzOutput from test script zExpected output: %rr&)	rIrJ�tuplerr'r(r)r-r.)
r2rM�expected_msgrDrNrOrPrQrRrSs
          r�_check_import_errorzCmdLineTest._check_import_error�s����&��,� 0�2��$�%5�6��$�'7�7��,�
�%�s�
�6>�
���C���Q�;��,�-=�q�,A�B�C��$�s�)���'�,�6�7��
�
�l�)�)�'�2�C�8rc��tdd�\}}}ttjj�jd�}|j
||�y)N�-czprint(__loader__)r&)r
r)r�	machinery�BuiltinImporterr.r-)r2rQrRrS�expecteds     r�test_dash_c_loaderzCmdLineTest.test_dash_c_loader�sD��'��.A�B���C���	�+�+�;�;�<�C�C�G�L���
�
�h��$rc�B�t�}	|jjd�|jj�t	|�}ttjj�jd�}|j||�y#t	|�}wxYw)Nsprint(__loader__)
r&)r�stdin�write�flushr
r)rr[r\r.r-)r2�prRr]s    r�test_stdin_loaderzCmdLineTest.test_stdin_loader�ss��
�N��	!�
�G�G�M�M�0�1�
�G�G�M�M�O��a�.�C��	�+�+�;�;�<�C�C�G�L���
�
�h��$���a�.�C�s�5B�
Bc#�K�|r(tdtj��}|j}n'tdtj��}|j
}		|j
d�}|dk(rn|j��(|��t|�|j�y#t|�|j�wxYw�w)Nz-i)�stderr�s>>> )
r�
subprocess�PIPErf�STDOUT�stdout�read�readliner
�close)r2�separate_stderrrcrfr5s     r�interactive_pythonzCmdLineTest.interactive_python�s�������T�*�/�/�:�A��X�X�F��T�*�*;�*;�<�A��X�X�F�
	���{�{�1�~���7�?�����!�	�
�G���N��L�L�N��
��N��L�L�N�s�AB>�-B�B>�B;�;B>c�*�|j|�5}|jjd�|jj�|j	d|j
j
�j��ddd�y#1swYyxYw)Ns
print('foo')
sfoo)rpr`rarbr*rkrm�strip)r2rorcs   r�check_repl_stdout_flushz#CmdLineTest.check_repl_stdout_flush�sb��
�
$�
$�_�
5��
�G�G�M�M�+�,�
�G�G�M�M�O����V�Q�X�X�%6�%6�%8�%>�%>�%@�A�6�
5�
5�s�A.B	�	Bc��|j|�5}|jjd�|jj�|r|jn|j
}|j
d|j��|j
d|j��|j
d|j��ddd�y#1swYyxYw)Ns1/0
s
Traceback sFile "<stdin>"sZeroDivisionError)rpr`rarbrfrkr-rm)r2rorcrfs    r�check_repl_stderr_flushz#CmdLineTest.check_repl_stderr_flush�s���
�
$�
$�_�
5��
�G�G�M�M�(�#�
�G�G�M�M�O�!0�Q�X�X�a�h�h�F��M�M�-����):�;��M�M�+�V�_�_�->�?��M�M�.����0A�B�
6�
5�
5�s�B0C�Cc�$�|j�yr�rs�r2s r�test_repl_stdout_flushz"CmdLineTest.test_repl_stdout_flush�����$�$�&rc�&�|jd�y�NTrwrxs r�&test_repl_stdout_flush_separate_stderrz2CmdLineTest.test_repl_stdout_flush_separate_stderr�����$�$�T�*rc�$�|j�yr�rurxs r�test_repl_stderr_flushz"CmdLineTest.test_repl_stderr_flush�rzrc�&�|jd�yr|r�rxs r�&test_repl_stderr_flush_separate_stderrz2CmdLineTest.test_repl_stderr_flush_separate_stderr�r~rc
���tj�5}t|d�}|j||||dtj
j|��ddd�y#1swYyxYw)N�script)r;�r�temp_dirrrTrr[�SourceFileLoader�r2rr3s   r�test_basic_scriptzCmdLineTest.test_basic_script�sX��
�
�
�
!�Z�+�J��A�K����{�K��)�4�(�2�2�C�C�,6�
�
8�"�
!�
!���=A�A$c	�f�tj�5}|jtjj|�|�t
|d�}tjj|�}|j||||dtjj�ddd�y#1swYyxYw)Nr�)r�temp_cwd�
assertTruer+�path�isabsr�basenamerTrr[r�)r2rr3�
relative_names    r�test_script_abspathzCmdLineTest.test_script_abspath�s����
�
�
!�Z��O�O�B�G�G�M�M�*�5�z�B�+�J��A�K��G�G�,�,�[�9�M����}�k�=�)�4�(�2�2�C�C�
E�"�
!�
!�s�B	B'�'B0c	�L�tj�5}t|d�}tj|d��tj|�tj|�}|j||||dtjj�ddd�y#1swYyxYw)Nr�T��doraise�
rr�r�
py_compile�compiler+�remover�make_legacy_pycrTrr[�SourcelessFileLoader�r2rr3�pyc_files    r�test_script_compiledz CmdLineTest.test_script_compiled�s}��
�
�
�
!�Z�+�J��A�K����{�D�9��I�I�k�"�$�4�4�[�A�H����x��'��T�(�2�2�G�G�
I�"�
!�
!���A<B�B#c	���tj�5}t|d�}|j||||dtj
j�ddd�y#1swYyxYw)N�__main__�r�r�s   r�test_directoryzCmdLineTest.test_directory�sQ��
�
�
�
!�Z�+�J�
�C�K����z�;�
�)�2�(�2�2�C�C�
E�"�
!�
!���;A�A"c	�L�tj�5}t|d�}tj|d��tj|�tj|�}|j||||dtjj�ddd�y#1swYyxYw)Nr�Tr�r�r�r�s    r�test_directory_compiledz#CmdLineTest.test_directory_compileds}��
�
�
�
!�Z�+�J�
�C�K����{�D�9��I�I�k�"�$�4�4�[�A�H����z�8�Z�)�2�(�2�2�G�G�
I�"�
!�
!�r�c��tj�5}d|z}|j||�ddd�y#1swYyxYw)N�"can't find '__main__' module in %r)rr�rX)r2r�msgs   r�test_directory_errorz CmdLineTest.test_directory_errors6��
�
�
�
!�Z�6��C�C��$�$�Z��5�"�
!�
!�s�6�?c	���tj�5}t|d�}t|d|�\}}|j	||||dt
j�ddd�y#1swYyxYw)Nr��test_zipr�)rr�rr	rT�	zipimport�zipimporter)r2rr3�zip_name�run_names     r�test_zipfilezCmdLineTest.test_zipfiles\��
�
�
�
!�Z�+�J�
�C�K�!0��Z��!U��H�h����x��8�X�r�(�4�4�
6�"�
!�
!�s�AA�A(c	�6�tj�5}t|d�}tj|dtj
j��}t|d|�\}}|j||||dtj�ddd�y#1swYyxYw�Nr�T)r��invalidation_moder�r�)rr�rr�r��PycInvalidationMode�	TIMESTAMPr	rTr�r��r2rr3�
compiled_namer�r�s      r�test_zipfile_compiled_timestampz+CmdLineTest.test_zipfile_compiled_timestamps���
�
�
�
!�Z�+�J�
�C�K�&�.�.��T�",�"@�"@�"J�"J�L�M�"1��Z��!W��H�h����x��8�X�r�(�4�4�
6�
"�
!�
!���A1B�Bc	�6�tj�5}t|d�}tj|dtj
j��}t|d|�\}}|j||||dtj�ddd�y#1swYyxYwr�)rr�rr�r�r��CHECKED_HASHr	rTr�r�r�s      r�"test_zipfile_compiled_checked_hashz.CmdLineTest.test_zipfile_compiled_checked_hash!s���
�
�
�
!�Z�+�J�
�C�K�&�.�.��T�",�"@�"@�"M�"M�O�M�"1��Z��!W��H�h����x��8�X�r�(�4�4�
6�
"�
!�
!�r�c	�6�tj�5}t|d�}tj|dtj
j��}t|d|�\}}|j||||dtj�ddd�y#1swYyxYwr�)rr�rr�r�r��UNCHECKED_HASHr	rTr�r�r�s      r�$test_zipfile_compiled_unchecked_hashz0CmdLineTest.test_zipfile_compiled_unchecked_hash+s���
�
�
�
!�Z�+�J�
�C�K�&�.�.��T�",�"@�"@�"O�"O�Q�M�"1��Z��!W��H�h����x��8�X�r�(�4�4�
6�
"�
!�
!�r�c��tj�5}t|d�}t|d|�\}}d|z}|j	||�ddd�y#1swYyxYw)N�not_mainr�r�)rr�rr	rX)r2rr3r�r�r�s      r�test_zipfile_errorzCmdLineTest.test_zipfile_error5sU��
�
�
�
!�Z�+�J�
�C�K�!0��Z��!U��H�h�6��A�C��$�$�X�s�3�	"�
!�
!�s�4A�Ac
�(�tj�5}tjj	|d�}t|�t
|d�}|jddg|||dtjj|��ddd�y#1swYyxYw)N�test_pkgr��-m�test_pkg.scriptrC�rr�r+r��joinrrrTrr[r��r2r�pkg_dirr3s    r�test_module_in_packagez"CmdLineTest.test_module_in_package<sz��
�
�
�
!�Z��g�g�l�l�:�z�:�G��W��+�G�X�>�K�����&7�8�+�{�)�:�(�2�2�C�C�#-�
�
/�	"�
!�
!���A*B�Bc���tj�5}t|ddd�\}}|jddg|||dtj
||��ddd�y#1swYyxYw)Nr�r�r�r�r���
PYTHONPATHrD�rr�r"rTr�r��r2rr�r�s    r�!test_module_in_package_in_zipfilez-CmdLineTest.test_module_in_package_in_zipfileFsd��
�
�
�
!�Z�!3�J�
�J�X`�!a��H�h�����&7�8�(�H�)�:�y�7L�7L�*2�
�
�
D�"�
!�
!�r�c���tj�5}t|dddd��\}}|jddg|||dtj
||�	�ddd�y#1swYyxYw)
Nr�r�r��)r!r�ztest_pkg.test_pkg.scriptztest_pkg.test_pkgr�r�r�s    r�$test_module_in_subpackage_in_zipfilez0CmdLineTest.test_module_in_subpackage_in_zipfileMsi��
�
�
�
!�Z�!3�J�
�J�X`�hi�!j��H�h�����&@�A�8�X�)�+>�(�4�4�*2�
�
�
D�"�
!�
!�r�c
�(�tj�5}tjj	|d�}t|�t
|d�}|jddg|||dtjj|��ddd�y#1swYyxYw)Nr�r�r�rCr�r�s    r�test_packagezCmdLineTest.test_packageUsy��
�
�
�
!�Z��g�g�l�l�:�z�:�G��W��+�G�Z�@�K�����j�1�;�*�J�
�(�2�2�C�C�#-�
�
/�	"�
!�
!�r�c
��tj�5}tjj	|d�}t|�t
|d�}tj|d��}tj|�tj|�}|jddg|||dtjj|��ddd�y#1swYyxYw)Nr�r�Tr�r�rC)rr�r+r�r�rrr�r�r�rr�rTrr[r�)r2rr�r3r�r�s      r�test_package_compiledz!CmdLineTest.test_package_compiled_s���
�
�
�
!�Z��g�g�l�l�:�z�:�G��W��+�G�Z�@�K�&�.�.�{�D�I�M��I�I�k�"�$�4�4�[�A�H�����j�1�8�'��Z�(�2�2�G�G�#-�
�
/�"�
!�
!�s�B+C	�	Cc���tj�5}tjj	|d�}t|�d}|j
ddg||��ddd�y#1swYyxYw)Nr�z7'test_pkg' is a package and cannot be directly executedr�rC�rr�r+r�r�rrX)r2rr�r�s    r�test_package_errorzCmdLineTest.test_package_errorlsY��
�
�
�
!�Z��g�g�l�l�:�z�:�G��W��*�C��$�$�d�J�%7��*�$�M�"�
!�
!�s�AA"�"A+c�2�tj�5}tjj	|d�}t|�tjj	|d�}t|�d}|j
ddg||��ddd�y#1swYyxYw)Nr�r�z^Cannot use package as __main__ module; 'test_pkg' is a package and cannot be directly executedr�rCr�)r2rr��main_dirr�s     r�test_package_recursionz"CmdLineTest.test_package_recursiontsw��
�
�
�
!�Z��g�g�l�l�:�z�:�G��W���w�w�|�|�G�Z�8�H��X��*�C�
�$�$�d�J�%7��*�$�M�"�
!�
!�s�A/B
�
Bc�2�tj�5}tj|��5tjj|d�}t
|d�t|d�}tddgt��ddi�\}}}td	kDrtt|��d
dz}|j|jd�|�|j||||||dt j"j$�ddd�ddd�y#1swY�xYw#1swYyxYw)N�r�r�z1import sys; print('init_argv0==%r' % sys.argv[0])r�r�r�rGFrzinit_argv0==%rr&)rr��
change_cwdr+r�r�rrr
rLr'r(r)r-r.rBrr[r�)r2rr�r3rQrRrSr]s        r�test_issue8202zCmdLineTest.test_issue8202s����
�
�
!�Z��%�%�:�6��'�'�,�,�z�:�>����"U�V�/���B��/��6G�i�,�i�ch�i���C���Q�;��$�s�)�$�+�d�2���
�
�h�o�o�g�6��<��"�"�;��C�#.��Z��#,�#6�#6�#G�#G�I�7�"�
!�6�6��"�
!�s#�D
�CD�0D
�D
	�D
�
Dc��tj�5}tj|��5tddd��5}|j	d�tddd�	�\}}}td
kDrtt|��ddz}|j|jd�|�ddd�ddd�ddd�y#1swY�xYw#1swY�xYw#1swYyxYw)
Nr�rZ�wr&��encodingr5z2import sys; print("sys.path[0]==%r" % sys.path[0])F)rGrzsys.path[0]==%rr�)rr�r��openrar
r'r(r)r-r.)r2r�frQrRrSr]s       r�"test_issue8202_dash_c_file_ignoredz.CmdLineTest.test_issue8202_dash_c_file_ignored�s����
�
�
!�Z��%�%�:�6��$��g�6�!��G�G�F�O�#3�D�L�#(�$*�L�B��S���{��d�3�i�(�0�2�5�H��M�M�(�/�/�'�":�C�@�7�7�"�
!�6�6��7�6��"�
!�s:�C�C�A'B;�"C�*C�;C�C�C	�C�Cc
��tj�5}t|d�}tj|��5t	ddd��5}|jd�t
ddgt��dd	i�\}}}|j||||||d
tjj�ddd�ddd�ddd�y#1swY�xYw#1swY�xYw#1swYyxYw)N�otherr�r�r�r&r�r5rGFr�)rr�rr�r�rar
rLrBrr[r�)r2rr3r�rQrRrSs       r�"test_issue8202_dash_m_file_ignoredz.CmdLineTest.test_issue8202_dash_m_file_ignored�s����
�
�
!�Z�+�J��@�K��%�%�:�6��$��g�6�!��G�G�F�O�#3�D�'�$F�L�$F�?D�$F�L�B��S��&�&�{�B��&1�;�
�B�&/�&9�&9�&J�&J�L�	7�7�"�
!�7�6��7�6��"�
!�s;�#C�C�AB:�!C�)C�:C�?C�C	�C�Cc�B�tj�5}tjj	|d�}t|ddd��5}|j
d�|j
d�td�D]}|j
d	��|j
d�ddd�tj|�
�5t|�\}}}ddd�|jd�|jd�ddd�y#1swY�dxYw#1swY�BxYw#1swYyxYw)Nz
issue20884.pyr��latin1�
)r��newlinez#coding: iso-8859-1
z"""
�zQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
r�r)rr�r+r�r�r�ra�ranger�r
r*)r2rr3r��_rQrRrSs        r�test_issue20884zCmdLineTest.test_issue20884�s����
�
�
!�Z��'�'�,�,�z�?�C�K��k�3��4�H�A����/�0����� ��r��A��G�G�M�*�#����� �I��%�%�:�6�/��<���C��7����S�#�&����S�#�&�"�
!�H�H��7�6��"�
!�s<�0D�AC=�D�8D	�,D�=D	�D�	D	�D�Dc'�K�tj�5}tj|��5tjj|d�}t
|g|���|��ddd�ddd�y#1swY�xYw#1swYyxYw�w)Nr�r�)rr�r�r+r�r�r)r2�argsrr�s    r�setup_test_pkgzCmdLineTest.setup_test_pkg�sd����
�
�
�
!�Z��$�$�*�5��g�g�l�l�:�z�:�G��W�$�t�$��M�6�"�
!�5�5��"�
!�s3�B�A<�1A0�A<�'	B�0A9	�5A<�<B�Bc��tdg|��ddi�\}}}tdkDrtt|��|j	|d�|S)Nr�rGFr)rr'r(r)r*)r2r�rQrRrSs     r�check_dash_m_failurez CmdLineTest.check_dash_m_failure�sD��,�T�K�D�K�U�K���C���Q�;��$�s�)������Q���
rc��|j�5}t|dd�}|jdgt���}|j	d|�ddd�y#1swYyxYw)Nr�z+if __name__ == '__main__': raise ValueErrorztest_pkg.others
ValueError)r�rr�rLr-)r2r�r3rSs    r�test_dash_m_error_code_is_onez)CmdLineTest.test_dash_m_error_code_is_one�sV���
 �
 �
"�g�+�G�W�,Y�[�K�+�$�+�+�,<�L�|�L�C��M�M�-��-�	#�
"�
"�s�7A�Ac���d}|D]e\}}|j|�5td|�\}}}|j|d�|j||�|j	d|�ddd��gy#1swY�rxYw)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)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)�subTestrr*�assertRegex�assertNotIn)r2�tests�name�regexrQr�rSs       r�test_dash_m_errorszCmdLineTest.test_dash_m_errors�sv��

��!�K�D�%����d�#�2�4��>�
��A�s�� � ��Q�'�� � ��e�,�� � ��s�3�	$�#�!�#�#�s�AA.�.A7	c��tj�5}tj|��5tjd�tdd�5	ddd�|j
d�}|j|d�|jd|�|jd|�ddd�ddd�y#1swY�axYw#1swY�xYw#1swYyxYw)Nr�r�ztest_pkg/__init__.pyc�wbsGError while finding module specification.*ImportError.*bad magic numbersis a packager)	rr�r�r+�mkdirr�r�rr�r2rrSs   r�test_dash_m_bad_pyczCmdLineTest.test_dash_m_bad_pyc�s���
�
�
�
!�Z��$�$�*�5��H�H�Z� ��-�t�4��5��+�+�J�7�C����S�2�
3�
���_�c�2����\�3�/�6�"�
!�5�4��6�5��"�
!�s;�C�"B<�B0�AB<�C�0B9�5B<�<C	�C�Cc�6�tj�5}tj|��5tdd�5	ddd�|j	d�}|jd|�ddd�ddd�y#1swY�=xYw#1swY�xYw#1swYyxYw)Nr�z
asyncio.pyr
s>Try using 'asyncio' instead of 'asyncio.py' as the module name)rr�r�r�r�r-rs   r�*test_hint_when_triying_to_import_a_py_filez6CmdLineTest.test_hint_when_triying_to_import_a_py_file�s~��
�
�
�
!�Z��$�$�*�5��l�D�)��*��+�+�L�9�C��M�M�@�AD�
F�6�"�
!�*�)��6�5��"�
!�s8�B�
B�A7�+B�&B�7B�<B�B	�B�Bc��ttttf}|D]�}|j}dj|�}|j
|�5|j|�5}|jd�}|j|jd�|�|jd|�|jd|�ddd�ddd���y#1swY�xYw#1swY��xYw)Nz%raise {0}('Exception in __init__.py')r��asciisException in __init__.pyr)�ImportError�AttributeError�	TypeError�
ValueError�__name__�formatrr�r�r-r.)r2�
exceptions�	exception�initr�rSs      r�test_dash_m_init_tracebackz&CmdLineTest.test_dash_m_init_tracebacks���"�>�9�j�I�
�#�I�!�*�*�I�:�A�A�)�L�D����i�(��'�'��-���/�/�
�;���
�
�i�.�.�w�7��=��
�
�9�3�?��
�
�l�C�0�	.�)�(�$�.�-��)�(�s%�
C�AC�3C�C�C�C	c��|j�5}d}t|d|�|jd�}|jd|�|jd|�|jd|�ddd�y#1swYyxYw)Nz1raise ImportError('Exception in __main__ module')r�r�sImportErrorsException in __main__ moduler)r�rr�r-)r2r��mainrSs    r�test_dash_m_main_tracebackz&CmdLineTest.test_dash_m_main_tracebacksh��
�
 �
 �
"�g�F�D��g�z�4�8��+�+�J�7�C��M�M�.�#�.��M�M�9�3�?��M�M�,��,�
#�
"�
"�s�AA1�1A:c��tjd�}tj�5}t	|d|�}t|�\}}}|j
d�jd�}|jt|�d�|j|djd��|j|djd	��|j|d
jd��ddd�y#1swYyxYw)Nz|            try:
                raise ValueError
            except:
                raise NameError from None
            r�rr��r�	Tracebackrz  File ��	NameError)�textwrap�dedentrr�rr�decode�splitr*�lenr��
startswith�r2r�rr3�exitcoderkrf�texts        r�test_pep_409_verbiagez!CmdLineTest.test_pep_409_verbiages������"����
�
�
!�Z�+�J��&�I�K�'<�[�'I�$�H�f�f��=�=��)�/�/��5�D����S��Y��*��O�O�D��G�.�.�{�;�<��O�O�D��G�.�.�y�9�:��O�O�D��G�.�.�{�;�<�"�
!�
!�s�CC4�4C=c�6�tjr6tjdvr$t	j
tj�}n2tjrtj}n|jd�d}tt	j�|�}|jtj|�t|�\}}}|jt|�|j�j!d�d|�d|���|jd|�y)N)�win32�darwin�
emscripten�wasizneed os_helper.TESTFN_NONASCIIzprint(ascii(__file__))
rzstdout=z stderr=r)r�TESTFN_UNDECODABLEr/�platformr+�fsdecode�TESTFN_NONASCII�skipTestrr,�
addCleanup�unlinkr
r*r�rstripr&)r2rrr3rQrkrfs       r�test_non_asciizCmdLineTest.test_non_ascii-s���

�(�(��L�L� I�I��;�;�y�;�;�<�D�
�
&�
&��,�,�D��M�M�:�;�,��'��	�	��T�6�B�����	�(�(�+�6�-�k�:���F�F�����+���M�M�O�"�"�7�+�%+�V�4�	6�	
����B�rc��tjd�}tj�5}t	|d|�}t|�\}}}|j
d�}|j|j�d�ddd�y#1swYyxYw)Nz�            import sys
            error = None
            try:
                raise ValueError('some text')
            except ValueError as err:
                error = err

            if error:
                sys.exit(error)
            r�rz	some text)	r$r%rr�rrr&r*r:r*s        r�)test_issue20500_exit_with_exception_valuez5CmdLineTest.test_issue20500_exit_with_exception_valueEst�����
"�
���
�
�
!�Z�+�J��&�I�K�'<�[�'I�$�H�f�f��=�=��)�D����T�[�[�]�K�8�	"�
!�
!�s�AB�B
c�$�d}tj�5}t|d|�}t|�\}}}t	j
t	j|�d�j�}|jd|�ddd�y#1swYyxYw)Nz
1 + 1 = 2
r�rz
    ^^^^^
)	rr�rr�io�
TextIOWrapper�BytesIOrlr-r*s        r�*test_syntaxerror_unindented_caret_positionz6CmdLineTest.test_syntaxerror_unindented_caret_positionWsr����
�
�
�
!�Z�+�J��&�I�K�'<�[�'I�$�H�f�f��#�#�B�J�J�v�$6��@�E�E�G�D��M�M�/�4�0�"�
!�
!�s�A&B�Bc�<�tjd�}tj�5}t	|d|�}t|�\}}}t
jt
j|�d�j�}|jd|�d}t	|d|�}t|�\}}}t
jt
j|�d�j�}|jd|�|jd|�ddd�y#1swYyxYw)Nz;            if True:
                1 + 1 = 2
            r�rz
    1 + 1 = 2
    ^^^^^
zif True:
    1 + 1 = 2
�)r$r%rr�rrr?r@rArlr-rr*s        r�(test_syntaxerror_indented_caret_positionz4CmdLineTest.test_syntaxerror_indented_caret_position`s������"����
�
�
!�Z�+�J��&�I�K�'<�[�'I�$�H�f�f��#�#�B�J�J�v�$6��@�E�E�G�D��M�M�8�$�?�$�
�,�J��&�I�K�'<�[�'I�$�H�f�f��#�#�B�J�J�v�$6��@�E�E�G�D����T�4�(��M�M�8�$�?�!"�
!�
!�s�CD�Dc���d}tj�5}t|d|�}t|�\}}}|j	|j�ddgd��ddd�y#1swYyxYw)Nzfoo = f"""{}
foo"""
r����)s    foo = f"""{}s               ^s;SyntaxError: f-string: valid expression required before '}'�rr�rrr*�
splitlines�r2r�rr3r+rkrfs       r�#test_syntaxerror_multi_line_fstringz/CmdLineTest.test_syntaxerror_multi_line_fstringwsf��)��
�
�
�
!�Z�+�J��&�I�K�'<�[�'I�$�H�f�f�����!�!�#�B�C�(��
�"�
!�
!���AA"�"A+c���d}tj�5}t|d|�}td|�\}}}|j	|j�ddgd��ddd�y#1swYyxYw)Nzfoo = """\q"""
r�z-WerrorrG)s    foo = """\q"""s          ^^^^^^^^s)SyntaxError: invalid escape sequence '\q'rHrJs       r�3test_syntaxerror_invalid_escape_sequence_multi_linez?CmdLineTest.test_syntaxerror_invalid_escape_sequence_multi_line�sm��$��
�
�
�
!�Z�+�J��&�I�K�'<��;�(�$�H�f�f�
����!�!�#�B�C�(��
�"�
!�
!�s�AA#�#A,c���d}tj�5}t|d|�}t|�\}}}|j	|j�ddddg�ddd�y#1swYyxYw)Nz?x = '' nothing to see here
';import os;os.system('echo pwnd')
r����s	    x = '�2SyntaxError: source code cannot contain null bytesrHrJs       r�test_syntaxerror_null_bytesz'CmdLineTest.test_syntaxerror_null_bytes�sl��U��
�
�
�
!�Z�+�J��&�I�K�'<�[�'I�$�H�f�f�����!�!�#�B�C�(� �I��
�"�
!�
!�rLc���ddg}tj�5}|D]C}t|d|�}t|�\}}}|j	|j�ddddg��E	ddd�y#1swYyxYw)Nz
'''
multilinestring
'''z
f'''
multilinestring
'''r�rPs    multilinestringrQrH)r2�scriptsrr�r3r�rfs       r�/test_syntaxerror_null_bytes_in_multiline_stringz;CmdLineTest.test_syntaxerror_null_bytes_in_multiline_string�s{��2�4T�U��
�
�
�
!�Z�!��/�
�H�f�M��4�[�A���1�f�� � ��%�%�'���,�.�M���"�"�
!�
!�s�A	A,�,A5c���tjd�}d|_tj�5}tj�5}t|d|�}t
d||��}t|�j�j�}|j|d|�|j||�t
d||��}t|�j�j�}|j||�t
d||��}t|�j�j�}|j|||�ddd�ddd�y#1swY�xYw#1swYyxYw)N�c            import sys
            for entry in sys.path:
                print(entry)
            r�z-EsrCrz-I)r$r%�maxDiffrr�rrr
r&rIr*r)	r2r��work_dirrr3rc�out_by_name�
out_by_dir�out_by_dir_isolateds	         r�-test_consistent_sys_path_for_direct_executionz9CmdLineTest.test_consistent_sys_path_for_direct_execution�s(�����"������
�
�
�
!�X�y�/A�/A�/C�z�+�J�
�F�K�K��U�K�X�>�A�%�a�.�/�/�1�<�<�>�K����[��^�Z�8����X�{�3��U�J�H�=�A�$�Q��.�.�0�;�;�=�J����Z��5��T�:�8�<�A�"-�a�.�"7�"7�"9�"D�"D�"F�����0�*�k�J�0D�
!�
!�/C�/C��
!�
!�s$�E�C9E�?E�E	�E�E%c���tjd�}d|_tj�5}t
jj|d�}tj|�t|d|�}tdd|��}t|�j�j�}|j|d|�|j||�tdd|��}t|�j�j�}|j||�t!dd|��\}}	}
|
j�j�}|j#d	|d
�ddd�y#1swYyxYw)NrW�
script_pkgr�z-smzscript_pkg.__main__rCrz-ImzNo module named script_pkg���)r$r%rXrr�r+r�r�rrrr
r&rIr*rrr-)r2r�rYrr3rc�
out_by_module�out_by_packager+rkrf�traceback_liness            r�-test_consistent_sys_path_for_module_executionz9CmdLineTest.test_consistent_sys_path_for_module_execution�s4�����"������
�
�
�
!�X������h��=�J��H�H�Z� �+�J�
�F�K�K��U�$9�x�H�A�'��N�1�1�3�>�>�@�M����]�1�-�x�8����Z��7��U�L�h�?�A�(��^�2�2�4�?�?�A�N����^�]�;�'<��|��(�$�H�f�f�%�m�m�o�8�8�:�O��M�M�6���8K�L�)"�
!�
!�s�D+E%�%E.c�<�d}|jtjj|��t	|dt
jt
j��}|j�\}}|jd|�|j|jd�y)Nznonexistingscript.pyT)r,rkrfz: can't open file r)�assertFalser+r��existsrrhri�communicater-�assertNotEqual�
returncode)r2r��procrRrSs     r�test_nonexisting_scriptz#CmdLineTest.test_nonexisting_script�sw��
(�����������/�0��F��#-�?�?�#-�?�?�4���#�#�%���S��
�
�*�C�0����D�O�O�Q�/rz	/dev/fd/0zrequires /dev/fd platform�freebsdz/devz/dev/fdz.Requires fdescfs mounted on /dev/fd on FreeBSDc�b�d}tj�5}t|d|�}t|d�5}t	d|j���dddd|j�f�	�}|j
�\}}|j|d
�ddd�ddd�y#1swY�xYw#1swYyxYw)Nz print("12345678912345678912345")z	script.py�rz/dev/fd/Trrr�)�	close_fds�pass_fdss12345678912345678912345
)rr�rr�r�filenorhr*)r2r�rYr3�fprcrRrSs        r�test_script_as_dev_fdz!CmdLineTest.test_script_as_dev_fds���4��
�
�
�
!�X�+�H�k�6�J�K��k�3�'�2� �8�B�I�I�K�=�!9�T�UV�WX�YZ�[]�[d�[d�[f�Tg�h���=�=�?���S�� � ��&B�C�(�"�
!�'�'��"�
!�s#�B%�AB�B%�B"	�B%�%B.r)F)Gr�
__module__�__qualname__rBrTrXr^rd�
contextlib�contextmanagerrprsruryr}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�rr
rrrr-r;r=rBrErKrNrRrUr]rdrl�unittest�
skipUnlessr+r�rg�skipIfr/r4r)�stat�st_devrt�rrr$r$\s���<@�9�D59�
C� 59�9� %�
%�������&B�C�'�+�'�+�8�
E�I�E�I�6�
6�6�6�6�4�/�D�D�/�/�N�	N�I�"
A�L�'�"�������.�4�(0�F�1�-�=�$ �09�$1�@�.�
�
��K�>#M�J
0��X���������4�6Q�R��X�_�_�S�\�\�,�,�Y�7�I��R�W�W�V�_�+�+�w�r�w�w�y�/A�/H�/H�H�E�G�
D�G�S�
Drr$c�,�tj�yr)r�
reap_childrenr~rr�tearDownModuler�s�����rr�)$rwr�importlib.machineryr�ryr/r+�os.pathr�rhr?r$�testr�test.supportrr�test.support.script_helperrrrr	r
rrr
r'rL�test_sourcerr"�TestCaser$r�rrr~rr�<module>r�s��������
�	����	���&�"�H�H�H��/�/��*��3��j;F��*���r
D�(�#�#�r
D�l��z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists