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.10/test/__pycache__/test_cmd_line.cpython-310.pyc
o

�i\��@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZeed�Zdd�ZGdd	�d	ej�Ze�e�d
�Gdd�dej��ZGd
d�dej�Zdd�Zedkrke��dSdS)�N)�support)�	os_helper)�spawn_python�kill_python�assert_python_ok�assert_python_failure� interpreter_requires_environmentZgettotalrefcountcCst|�}|��}||fS�N)r�wait)�p�data�
returncode�r�//usr/local/lib/python3.10/test/test_cmd_line.py�_kill_python_and_exit_codesrc@s`eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
�e�d�dd��Z
dd�Zdd�Zdd�Zdd�Zdd�Ze
�ejd�dd��Ze
�ejd�dd ��Ze
�ejd!kd"�d#d$��Ze
�ejd!kd"�d%d&��Ze
�ejd'kpxejd(�d)d*��Zd+d,�Zd-d.�Z d/d0�Z!d1d2�Z"d3d4�Z#d5d6�Z$d7d8�Z%d9d:�Z&d;d<�Z'd=d>�Z(d?d@�Z)dAdB�Z*dCdD�Z+e
�e,j-dEkdF�e
�ejdGkdH�dIdJ���Z.dKdL�Z/dMdN�Z0dOdP�Z1dQdR�Z2dSdT�Z3dUdV�Z4dWdX�Z5e
�e�dY�dZd[��Z6d\d]�Z7d^d_�Z8d`d`da�dbdc�Z9ddde�Z:dydgdh�Z;didj�Z<dkdl�Z=dmdn�Z>dodp�Z?e
�ejd!kdq�drds��Z@dtdu�ZAdvdw�ZBdxS)z�CmdLineTestcCstd�td�dS)N�.z< .)r��selfrrr�test_directoriesszCmdLineTest.test_directoriescCsBt|�\}}}|�|dkp|�d��|�d|�|�d|�dS)N��
s	Traceback)r�
assertTrue�endswith�assertNotIn)rZcmd_line�rc�out�errrrr�verify_valid_flag"szCmdLineTest.verify_valid_flagcCs|�d�|�d�dS)Nz-Oz-OO�rrrrr�
test_optimize(s
zCmdLineTest.test_optimizecC�|�d�dS)N�-Srrrrr�test_site_flag,�zCmdLineTest.test_site_flagcCsBtd�\}}}|��}|�d|d�d�|dd���d�dS)Nz-hsusagerr��ascii)r�
splitlines�assertIn�join�decode)rrrr�linesrrr�
test_usage/szCmdLineTest.test_usagecCsTdtjdd��d�}dD]}t|�\}}}|�|�|��|�|�|��qdS)NzPython %d.%d�r&)z-Vz	--versionz-VV)�sys�version_info�encoderZassertFalse�
startswithr)r�versionZswitchrrrrrr�test_version7s�zCmdLineTest.test_versioncCs8td�\}}}|�d|�td�\}}}|�d|�dS)Nz-vsstack overflowz-vv)rr�rrrrrrr�test_verbose>szCmdLineTest.test_verbosez6Cannot run -E tests when PYTHON env vars are required.cCs:dd�}|�}|�|i�|dd�}|�|ddd��dS)NcWs4tjdf|}|d7}t�|�}t|��d�}|S)N�-E)�-c� import sys; print(sys._xoptions)r)r.�
executable�
subprocess�check_output�evalr')�argsr�optsrrr�get_xoptionsJs

z/CmdLineTest.test_xoptions.<locals>.get_xoptionsz-Xaz	-Xb=c,d=eTzc,d=e)�a�b)�assertEqual)rr?r>rrr�
test_xoptionsGs
	
zCmdLineTest.test_xoptionscs��fdd�}d}|d|�\}}}��|��d���|d�|ddd|�\}}}��|��d	�tr:��|d
�dS��|d�dS)Ncsdtjg}|�|�tj}tj|||d�}|��\}}|j��|j	��|j
}��|d�|||fS)N��stdout�stderrr)r.r9�extendr:�PIPE�Popen�communicaterE�closerFr
rB)r=�cmdrHrrrrrrr�
run_pythonZs



z1CmdLineTest.test_showrefcount.<locals>.run_pythonr8r7s{}r�-X�showrefcounts{'showrefcount': True}s^\[\d+ refs, \d+ blocks\])rB�rstrip�Py_DEBUG�assertRegex)rrM�coderrrrrr�test_showrefcountYszCmdLineTest.test_showrefcountcCs0td�tdd�tddd�tdddd�dS)N�-mZ
fnord43520xyzZrunpy�timeit�-n�1�rrrrrr�test_run_moduleus
zCmdLineTest.test_run_modulecCs\tddddd�}|j�d�|j�d�t|�}|�|�d�d	k�|�|�d
�d	k�dS)N�-irUrVrWrXsTimer
�exit()
s1 loop���s__main__.Timer)r�stdin�writerr�find)rrrrrr�test_run_module_bug1764407�sz&CmdLineTest.test_run_module_bug1764407cCsbt��}tj�t��d�}t�|��tddd�tddd�Wd�dS1s*wYdS)N�testrU�unittestztest/test_longexp.pyz./test/test_longexp.py)	�os�getcwd�path�dirname�__file__�removesuffixrZ
change_cwdr)rZ	defaultwdZprojectlibpathrrr�test_relativedir_bug46421�s"�z%CmdLineTest.test_relativedir_bug46421cCs td�tdd�tdd�dS)Nr7zraise Exception�passrYrrrr�
test_run_code�s
zCmdLineTest.test_run_codezneed os_helper.FS_NONASCIIcCs"dtjttj�f}td|�dS)Nzassert(ord(%r) == %s)r7)r�FS_NONASCII�ordr)rZcommandrrr�test_non_ascii�s�zCmdLineTest.test_non_asciicCs<tj}d|�d�}td|�}|�|j��t|��d��dS)Nz# coding: latin1
print(ascii('z'))r7r&)rrmrrBrrPr&r0)rZchrL�resrrr�test_coding�s
 zCmdLineTest.test_coding�win32z Windows has a native unicode APIcCs�d}tj��}d|d<d|d<d|d}tjtjd|gtjtj|d	�}|�	�\}}|j
d
kr2d}n|j
dkr:d
}n	td|j
|f��|�|�sPtd||f��dS)N���C�LC_ALL�0ZPYTHONCOERCECLOCALEsimport locale; print(ascii("s""), locale.getpreferredencoding())r7)rErF�envr%s3Unable to decode the command from the command line:rs'\xff' z Unknown exit code: %s, output=%az%a doesn't start with %a)
rd�environ�copyr:rIr.r9rH�STDOUTrJr
�AssertionErrorr1)rZundecodablerwrSrrErF�patternrrr�test_undecodable_code�s0
���
�


�z!CmdLineTest.test_undecodable_codec	s�d�tjd�g}�fdd�}�fdd�}�fdd�}d	�d
�}d}||g}|||fD],}|j|d��|D]}	||	�}
|�|
j��t|	��q5Wd�n1sQwYq*dS)
Nz;import sys, os; s=os.fsencode(sys.argv[1]); print(ascii(s))r7cs tjd�|g}tj|tjdd�S)Nr7T�rE�text�r.r9r:�runrH��argrL�rSrr�run_default�sz6CmdLineTest.test_invalid_utf8_arg.<locals>.run_defaultcs4tjd�|g}ttj�}d|d<tj|tjd|d�S)Nr7rtruT)rErrw)r.r9�dictrdrxr:r�rH)r�rLrwr�rr�run_c_locale�s

�z7CmdLineTest.test_invalid_utf8_arg.<locals>.run_c_localecs$tjddd�|g}tj|tjdd�S)NrN�utf8r7Tr~r�r�r�rr�
run_utf8_mode�sz8CmdLineTest.test_invalid_utf8_arg.<locals>.run_utf8_mode�e:é, euro:€, non-bmp:􏿿�utf-8s��é�������)�run_cmd)r.r9r0�subTestrBrErPr&)rZbase_cmdr�r�r�Z
valid_utf8Zinvalid_utf8Z	test_argsr�r��procrr�r�test_invalid_utf8_arg�s$	
�����z!CmdLineTest.test_invalid_utf8_arg�darwinz%test specific to Mac OS X and Androidc	Cs�d�d�}d}|�dd�}t|��d�d}tj��}d|d<tjtj	d	||ftj
|d
�}|��\}}|�||�|�|j
d�dS)Nr�r�z%import sys; print(ascii(sys.argv[1]))�surrogateescaper&rrtrur7)rErwr)r0r*r&rdrxryr:rIr.r9rHrJrBr
)	rrrSZdecoded�expectedrwrrErFrrr�test_osx_android_utf8s

�z!CmdLineTest.test_osx_android_utf8cCs@t�d�}tjd|g}tj|tjtjddd�}|�|jd�dS)Nz�
            import sys
            out = sys.stdout
            print(out.isatty(), out.write_through, out.line_buffering)
            err = sys.stderr
            print(err.isatty(), err.write_through, err.line_buffering)
        r7T)rErFr�checkz#False False False
False False True
)	�textwrap�dedentr.r9r:r�rHrBrE)rrSr=r�rrr�%test_non_interactive_output_bufferings

��z1CmdLineTest.test_non_interactive_output_bufferingcCs�dD]>}d|}tdd|�\}}}|dkr|n|}|�|dd|�d|}tdd|�\}}}|dkr5|n|}|�|dd	|�qdS)
NrDz6import os, sys; sys.%s.buffer.write(b'x'); os._exit(0)�-ur7rF�xzbinary %s not unbufferedz.import os, sys; sys.%s.write('x'); os._exit(0)ztext %s not unbuffered�rrB)r�streamrSrrrrrrr�test_unbuffered_output(s���z"CmdLineTest.test_unbuffered_outputcCsTd}tdd|�}|j�d�|j��t|�\}}|�|d�|�|�d�|�dS)Nz/import sys; sys.stdout.write(sys.stdin.read(1))r�r7r�r)rr^r_�flushrrBrr1)rrSrrrrrr�test_unbuffered_input8s
z!CmdLineTest.test_unbuffered_inputcCsXd}d}|tj|}d}tdd||d�\}}}|�|�d�|�|�|�d�|�dS)NA�ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEA�FGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJFGHIJ��if 1:
            import sys
            path = ":".join(sys.path)
            path = path.encode("ascii", "backslashreplace")
            sys.stdout.buffer.write(path)r"r7�Z
PYTHONPATHr&)rd�pathseprr(r0)rZpath1Zpath2rfrSrrrrrr�test_large_PYTHONPATHBs�z!CmdLineTest.test_large_PYTHONPATHcCs<d}td|dd�\}}}td|dd�\}}}|�||�dS)Nr�r7�r�F)Z
__isolatedr�)rrSZrc1Zout1Zerr1Zrc2Zout2Zerr2rrr� test_empty_PYTHONPATH_issue16309Qsz,CmdLineTest.test_empty_PYTHONPATH_issue16309cCs�dD]B}tj��}||d<tjtjdgtjtjtj|d�}d}|j	�
t|��d�d�|j	�
d�t
|�}t|��|d	�}|�||�qdS)
N)r&zlatin-1r�ZPYTHONIOENCODINGr[)r^rErFrwua=é b=� c=𐀀 d=􏿿r&rr\�backslashreplace)rdrxryr:rIr.r9rHrzr^r_r&r0r�reprr()r�encodingrwrrr�escapedrrr�test_displayhook_unencodablebs"
��z(CmdLineTest.test_displayhook_unencodablec	Cs�t�d��B}tj�d�}|�|�d��|��|�d�t	j
tjd|f|t	j
d��}|��\}}Wd�n1s;wYWd�n1sJwY|�|��|�dS)Nzwb+�ASCII)sabcsdefrr7)r^rE)�tempfile�NamedTemporaryFilerd�linesepr0r_r)r��seekr:rIr.r9rHrJrBrP)rrSr�r^�sepr�rErFrrr�check_inputts

����	zCmdLineTest.check_inputcC�|�dd�dS)Nz-import sys; print(repr(sys.stdin.readline()))s'abc\n'�r�rrrr�test_stdin_readline�s�zCmdLineTest.test_stdin_readlinecCr�)Nzprint(repr(input()))s'abc'r�rrrr�test_builtin_input�s�zCmdLineTest.test_builtin_inputcCsVd}td|�\}}}tjdkr|�d|�|�d|�dS|�d|�|�d|�dS)Nz�if 1:
            import sys
            print(1)
            print(2)
            print(3, file=sys.stderr)
            print(4, file=sys.stderr)r7rrs1
2
s3
4
s1
2
s3
4
)rr.�platformrB�rrSrrrrrr�test_output_newline�s
zCmdLineTest.test_output_newlinecCs4tdd�\}}}|�|�dd�d�|�d|�dS)Nr7�'r&�ignore�SyntaxErrorr)rrRr*rBr4rrr�test_unmached_quote�szCmdLineTest.test_unmached_quotecCsDd}td|�\}}}|�d|�|�d|�|�|�dd�d�dS)Nz�if 1:
            import os, sys, test.support
            test.support.SuppressCrashReport().__enter__()
            sys.stdout.write('x')
            os.close(sys.stdout.fileno())r7r�xr&r�z"Exception ignored in.*
OSError: .*)rrBrRr*r�rrr�test_stdout_flush_at_shutdown�s�z)CmdLineTest.test_stdout_flush_at_shutdowncCs$d}td|�\}}}|�d|�dS)Nzimport sys; sys.stdout.close()r7rr�r�rrr�test_closed_stdout�szCmdLineTest.test_closed_stdout�posixztest needs POSIX semantics�vxworksz.test needs preexec support in subprocess.Popencsfdj�d�}�fdd�}tjtjdd|gtjtjtj|d�}|��\}}|�|d�|�|jd	�dS)
Nz�if 1:
            import os, sys
            for i, s in enumerate({streams}):
                if getattr(sys, s) is not None:
                    os._exit(i + 1)
            os._exit(42)��streamscs>d�vr	t�d�d�vrt�d�d�vrt�d�dSdS)Nr^rrEr%rFr-)rdrKrr�rr�preexec�s

�z+CmdLineTest._test_no_stdio.<locals>.preexecr6r7)r^rErF�
preexec_fnr�*)	�formatr:rIr.r9rHrJrBr
)rr�rSr�rrrrr�r�_test_no_stdio�s��zCmdLineTest._test_no_stdiocC�|�dg�dS)Nr^�r�rrrr�
test_no_stdin��zCmdLineTest.test_no_stdincCr�)NrEr�rrrr�test_no_stdout�r�zCmdLineTest.test_no_stdoutcCr�)NrFr�rrrr�test_no_stderr�r�zCmdLineTest.test_no_stderrcCs|�gd��dS)N)r^rErFr�rrrr�test_no_std_streams�szCmdLineTest.test_no_std_streamscCs.|�d�g}tj�dd�dkrttj�}|d=d|d<ni}td�D]}d}td|fi|��\}}}|�|d	�|�|�q#t	t
|��}|jt|�d
d�
|�d�d
}td|dd�\}}}|�d|�td|dd�\}}}|�d|�td|dd�\}}}|�d|�tdd|dd�\}}}|�d|�dS)Nz-R�PYTHONHASHSEED�randomrXZ
__cleanenv�zprint(hash("spam"))r7rr%z83 runs produced an identical random hash  for "spam": {})�msgz<import sys; print("random is", sys.flags.hash_randomization)r��r�srandom is 1rvsrandom is 0)rrdrx�getr��rangerrB�append�sorted�setZ
assertGreater�lenr�r()rZhashesrw�irSrrrrrr�test_hash_randomization�s4


�z#CmdLineTest.test_hash_randomizationcCsftj}|�tj|�t|ddd��}td|d�td|d�Wd�n1s(wYt|�dS)N�wr��r�z
import sys)�filezdel sys.modules['__main__'])rZTESTFNZ
addCleanup�unlink�open�printr)r�filenameZscriptrrr�test_del___main__s�zCmdLineTest.test_del___main__cCs�tdd�\}}}|�d|�|�|���d�d�|�d|�tddd�\}}}|�d|�|�|���d�d�|�d|�tdddd�\}}}|�d|�|�d|�|�|���d�d�|�d|�dS)	Nr6z-zsUnknown option: -zr%r)Zwithoutz-asUnknown option: -a)rr(rBr'�countrr4rrr�test_unknown_optionssz CmdLineTest.test_unknown_options�6Cannot run -I tests when PYTHON env vars are required.c	CsD|�d�|�d�tddddd�\}}}|�|��d�t���w}tj�|d�}tj�|d	�}t	|d
dd��
}|�
d
�Wd�n1sGwYt	|d
dd��}|�
d�|�
d�Wd�n1shwY|jtj
tjtj|g|tjd�tjtjd|g|d�}|�|��d�Wd�dS1s�wYdS)N�-Iz-IEsr7zSfrom sys import flags as f; print(f.no_user_site, f.ignore_environment, f.isolated)r�)Zdummyvars1 1 1zuuid.pyzmain.pyr�r�r�z)raise RuntimeError('isolated mode test')
zimport uuid
zprint('ok')
)�cwdrF)r�sok)rrrB�stripr�temp_cwdrdrfr)r�r_ZassertRaisesr:�CalledProcessErrorr;r.r9�DEVNULL)rrrrZtmpdirZfake�main�frrr�test_isolatedmode%s6

�
�
�
��"�zCmdLineTest.test_isolatedmodec	Cs~dD]:\}}t||||d�}tt|��}d|�d|�d�}|j|d��td|fi|��Wd�n1s7wYqdS)N))r�r)rXr%)rr%)�2r-�ZPYTHONDEBUGZPYTHONOPTIMIZEZPYTHONDONTWRITEBYTECODEZ
PYTHONVERBOSEz�import sys; sys.stderr.write(str(sys.flags)); sys.exit(not (
                    sys.flags.debug == sys.flags.optimize ==
                    sys.flags.verbose ==
                    z:
                    and sys.flags.dont_write_bytecode == z
                )))Zenvar_valuer7)r��int�boolr�r)r�valuer��env_vars�dont_write_bytecoderSrrr�test_sys_flags_set@s&����
���zCmdLineTest.test_sys_flags_setc

Cst�}dddddd|dfg}|D]s\}}}|durdnd|�d	�}d
|�d�}d|g}|dur1ind
|i}	||urBddg|dd�<n|durQdd|��g|dd�<|j||d��#t���t|i|	��Wd�n1sowYWd�n1s~wYqdS)N)NNN)�fooNr�)N�barr�)r�r�r�)r�r�Nr�zis Nonez== "�"z,import sys; sys.exit(not sys.pycache_prefix �)r7ZPYTHONPYCACHEPREFIXrN�pycache_prefixrzpycache_prefix=)�envval�opt)�objectr�rr�r)
rZNO_VALUE�casesr�r�r�Z
exp_clauserSr=rwrrr�test_set_pycache_prefixWs2�	
�����z#CmdLineTest.test_set_pycache_prefixT)�check_exitcode�xdevcGs�ttj�}|�dd�|�dd�|�dd�|r#tjddg|�R}ntjg|�R}tj|tjtj	d|d�}|r@|�
|jd|�|j�
�S)	N�PYTHONWARNINGS�
PYTHONDEVMODE�PYTHONMALLOCrN�devT�rErF�universal_newlinesrwr)r�rdrx�popr.r9r:r�rHrzrBr
rErP)rrrr=rwr�rrr�run_xdevqs 
�
zCmdLineTest.run_xdevcCs~d}|jd|dd�}|�|d�|�d|�}|�|d�d}tr#d}nd	}|�d|�}|�||�|�d
d|�}|�|d|���|�dd|�}|�|d
|���|�dd|�}|�|d|���zddl}Wn	typYn.wd}t���|jd|dd�}Wd�n1s�wYt��r�d}nd}|�||�zddl}Wn
ty�YdSwd}|�d|�}|�|d�dS)N�%import sys; print(sys.flags.dev_mode)r7F)r�False�Truez\import warnings; print(' '.join('%s::%s' % (f[0], f[2].__name__) for f in warnings.filters))zdefault::Warningz�default::Warning default::DeprecationWarning ignore::DeprecationWarning ignore::PendingDeprecationWarning ignore::ImportWarning ignore::ResourceWarningz-bzdefault::BytesWarning �-bbzerror::BytesWarning z-Werrorzerror::Warning r�<import _testcapi; print(_testcapi.pymem_getallocatorsname()))r�pymalloc_debug�malloc_debugz5import faulthandler; print(faulthandler.is_enabled()))	rrBrQ�	_testcapi�ImportErrorrZSuppressCrashReport�
with_pymalloc�faulthandler)rrSr�expected_filtersrZ
alloc_namerrrr�	test_xdev�sL�
��zCmdLineTest.test_xdevFcCsx|rd}nd}|d7}tjd|dd|f}ttj�}|�dd�||d<tj|tjtj	d	|d
�}|�
|jd|�|j�
�S)Nz�import sys; from test.support.import_helper import import_fresh_module; warnings = import_fresh_module('warnings', blocked=['_warnings']); zimport sys, warnings; zKprint(' '.join('%s::%s' % (f[0], f[2].__name__) for f in warnings.filters))z-Wrr7rrTrr)r.r9r�rdrxr
r:r�rHrzrBr
rErP)rZcmdline_optionZenvvar�
use_pywarningrSr=rwr�rrr�check_warnings_filters�s 
�
z"CmdLineTest.check_warnings_filterscCsHd}ts|d7}|�dd�}|�||�|jdddd�}|�||�dS)Nz9error::BytesWarning once::UserWarning always::UserWarningz� default::DeprecationWarning ignore::DeprecationWarning ignore::PendingDeprecationWarning ignore::ImportWarning ignore::ResourceWarningzonce::UserWarningzalways::UserWarningT)r)rQrrB)rrrrrr�test_warnings_filter_precedence�s��z+CmdLineTest.test_warnings_filter_precedencecCs�d}ttj�}|�dd�|dur||d<n|�dd�tjd|f}tj|tjtj	d|d�}|�
|j��|�|�
|j
d�dS)Nrrrr7Trr)r�rdrxr
r.r9r:r�rHrzrBrErPr
)r�env_var�namerSrwr=r�rrr�check_pythonmalloc�s

�zCmdLineTest.check_pythonmallocc	Cs�t��}|rtr
dnd}d}ntrdnd}d}d|fd|fddg}|r(|�d�|D]!\}}|j||d	��|�||�Wd�n1sFwYq*dS)
Nr�pymallocr�malloc�debug)r r )rr))rr)rr)rr)rrrQrGr�r)rrZdefault_nameZdefault_name_debugZtestsrrrrr�test_pythonmalloc�s&�
���zCmdLineTest.test_pythonmalloccCs�d}ttj�}|�dd�tjd|f}tj|tjd|d�}|�	|j
��d�|�	|jd|�d|d<tj|tjd|d�}|�	|j
��d	�|�	|jd|�dS)
Nrrr7T)rEr	rwr
rrXr)
r�rdrxr
r.r9r:r�rHrBrErPr
)rrSrwr=r�rrr�test_pythondevmode_envs

�
�z"CmdLineTest.test_pythondevmode_envz!bpo-32457 only applies on WindowscCsbtjddf}tj�tj�\}}|d|}tj|tj|d�}|�|j	d|�|�|j
��d�dS)Nr7zprint(0)z\.\.\.\)rEr9r�0)r.r9rdrf�splitr:r�rHrBr
rEr�)rr=�prefixZexer9r�rrr�test_argv0_normalization&s
�z$CmdLineTest.test_argv0_normalizationcCsNtjddg}tj|tjtjdd�}d}|�|j�|�|j�|�|j	d�dS)Nr�z--unknown-optionT)rErFrz'unknown option --unknown-option
usage: r)
r.r9r:r�rHrrFr1�assertNotEqualr
)rr=r��err_msgrrr�test_parsing_error2s�zCmdLineTest.test_parsing_errorcCsBd}tddd|�tddd|�tddd|�tddd|dd�td|d	d�td|d
d�dd�}td|�}|�||�d
t��f�tddd|�}|�||�d�tddd|�}|�||�d�tddd|�}|�||�d�td|dd�}|�||�d�td|dd�}|�||�d�tddd|dd�}|�||�d�dS)NzMimport sys; print(sys.flags.int_max_str_digits, sys.get_int_max_str_digits())rN�int_max_str_digitsr7zint_max_str_digits=foozint_max_str_digits=100Z4000)ZPYTHONINTMAXSTRDIGITSr�Z100cSs&|j���d�}tdd�|��D��S)Nr�css�|]}t|�VqdSr	)r�)�.0r�rrr�	<genexpr>Js�zGCmdLineTest.test_int_max_str_digits.<locals>.res2int.<locals>.<genexpr>)rr�r*�tupler%)rprrrr�res2intHsz4CmdLineTest.test_int_max_str_digits.<locals>.res2intr]zint_max_str_digits=0)rrzint_max_str_digits=4000)�r0zint_max_str_digits=100000)順r1rvzint_max_str_digits=6000)�pr2)rrrBr.�get_int_max_str_digits)rrSr/rprrr�test_int_max_str_digits<s6
�
�z#CmdLineTest.test_int_max_str_digitsN)F)C�__name__�
__module__�__qualname__rrr r#r,r3r5rc�skipIfrrCrTrZrarjrlZ
skipUnlessrrmrorqr.r�r}r�rZ
is_androidr�r�r�r�r�r�r�r�r�r�r�r�r�r�rdrr�r�r�r�r�r�r�r�r�r�rrrrrrr"r#r'r*r4rrrrrs�	�
	

�
!�
+�

	�%�

;�


rr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�IgnoreEnvironmentTestcKsd�|�}tdd|fi|��S)Nz@import sys; sys.stderr.write(str(sys.flags)); sys.exit(not ({}))r6r7)r�r)r�	predicater�rSrrr�run_ignoring_varsds
z'IgnoreEnvironmentTest.run_ignoring_varscCsd}|jd�|�|d�dS)NZshould_be_ignoredz'{}' not in sys.pathr�)r;r�)rrfrrr�test_ignore_PYTHONPATHls
�z,IgnoreEnvironmentTest.test_ignore_PYTHONPATHcCs|jddd�dS)Nz!sys.flags.hash_randomization == 1rvr��r;rrrr�test_ignore_PYTHONHASHSEEDqs
�z0IgnoreEnvironmentTest.test_ignore_PYTHONHASHSEEDcCsd}|j|ddddd�dS)Nz�
            (sys.flags.debug == sys.flags.optimize ==
             sys.flags.dont_write_bytecode == sys.flags.verbose == 0)
        rXr�r=)rZexpected_outcomerrr�test_sys_flags_not_setus
�z,IgnoreEnvironmentTest.test_sys_flags_not_setN)r5r6r7r;r<r>r?rrrrr9`s
r9c@s$eZdZdd�Zdd�Zdd�ZdS)�SyntaxErrorTestscCsJtjtjdg|tjtjd�}|�|jd�|�|jd�|�d|j�dS)N�-)�inputrErFrs
SyntaxError)	r:r�r.r9rHr(r
rFr()rrSr�rrr�check_string�s�zSyntaxErrorTests.check_stringcCr!)Ns(1+2+3�rCrrrr�test_tokenizer_error_with_stdin�r$z0SyntaxErrorTests.test_tokenizer_error_with_stdincCr!)Ns'\u1f'rDrrrr�*test_decoding_error_at_the_end_of_the_line�r$z;SyntaxErrorTests.test_decoding_error_at_the_end_of_the_lineN)r5r6r7rCrErFrrrrr@�sr@cCst��dSr	)r�
reap_childrenrrrr�tearDownModule�srH�__main__)rdr:r.r�r�rcrbrZtest.supportrZtest.support.script_helperrrrrr�hasattrrQrZTestCaserr8r9r@rHr5r�rrrr�<module>s6
I�!�