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_regrtest.cpython-310.pyc
o

�i��@sbdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZddlmZddlmZmZee	d�Zej�ej�e�dd�Zej�ej�e��Zd	Z e�!d
�Z"Gdd�dej#�Z$Gd
d�dej#�Z%Gdd�de%�Z&Gdd�de%�Z'Gdd�de%�Z(Gdd�dej#�Z)e*dkr�e�+�dSdS)zM
Tests of regrtest.py.

Note: test_regrtest cannot be run twice in parallel.
�N)�libregrtest)�support)�	os_helper)�utils�setupZgettotalrefcountz..z5[0-9]+:[0-9]+:[0-9]+ (?:load avg: [0-9]+\.[0-9]{2} )?z�
    from signal import SIGINT, raise_signal
    try:
        raise_signal(SIGINT)
    except ImportError:
        import os
        os.kill(os.getpid(), SIGINT)
    c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�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&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRS)S�ParseArgsTestCasezC
    Test regrtest's argument parsing, function _parse_args().
    c	Cspt���"}|�t��
t�|�Wd�n1swYWd�n1s)wY|�||���dS�N)rZcaptured_stderr�assertRaises�
SystemExitr�_parse_args�assertIn�getvalue)�self�args�msg�err�r�//usr/local/lib/python3.10/test/test_regrtest.py�
checkError.s��zParseArgsTestCase.checkErrorcCs�dD]O}|j|d��?t���#}|�t��t�|g�Wd�n1s&wYWd�n1s5wY|�d|���Wd�n1sLwYqdS)N)z-hz--help��optzRun Python regression tests.)	�subTestrZcaptured_stdoutr	r
rrrr
)rr�outrrr�	test_help3s
������zParseArgsTestCase.test_helpcCs>t�ddg�}|�|jd�|�dgd�|�ddgd�dS)N�	--timeoutz4.2g������@�expected one argument�foozinvalid float value)rr�assertEqual�timeoutr�r�nsrrr�test_timeout;szParseArgsTestCase.test_timeoutcCst�dg�}|�|j�dS)N�--wait)rr�
assertTrue�waitrrrr�	test_waitAszParseArgsTestCase.test_waitcCs.t�ddg�}|�|jd�|�dgd�dS)Nz
--worker-argsz[[], {}]r)rrrZworker_argsrrrrr�test_worker_argsEsz"ParseArgsTestCase.test_worker_argsc	C�ddD]-}|j|d��t�|dg�}|�|jd�|�|gd�Wd�n1s*wYqdS)N)z-S�--startrrr)rrrr�startr�rrr rrr�
test_startJ����zParseArgsTestCase.test_startcCs�t�dg�}|�|jd�t�dg�}|�|jd�t�dg�}|�|jd�t�dgd�}|�|jd�t�g�}|�|jd�dS)N�-v�z-vvv��	--verboser)rrr�verboserrrr�test_verboseQs
zParseArgsTestCase.test_verbosec	C�RdD]$}|j|d��t�|g�}|�|j�Wd�n1s!wYqdS)N)�-wz
--verbose2r)rrrr#Zverbose2r*rrr�
test_verbose2]����zParseArgsTestCase.test_verbose2c	Cr3)N)�-Wz
--verbose3r)rrrr#Zverbose3r*rrr�
test_verbose3cr6zParseArgsTestCase.test_verbose3c	Cs`dD]+}|j|d��t�|g�}|�|j�|�|jd�Wd�n1s(wYqdS)N)�-q�--quietrr)rrrr#�quietrr1r*rrr�
test_quietis���zParseArgsTestCase.test_quietc	Cr3)N)z-o�	--slowestr)rrrr#Z
print_slowr*rrr�test_slowestpr6zParseArgsTestCase.test_slowestcCs4t�dg�}|�|j�t�dg�}|�|j�dS)Nz--headerr0)rrr#�headerrrrr�test_headervszParseArgsTestCase.test_headerc	Cr3)N)�-rz--randomizer)rrrr#�	randomizer*rrr�test_randomize}r6z ParseArgsTestCase.test_randomizecCsJt�ddg�}|�|jd�|�|j�|�dgd�|�ddgd�dS)Nz
--randseedZ12345i90rr�invalid int value)rrrZrandom_seedr#rBrrrrr�
test_randseed�s
zParseArgsTestCase.test_randseedc	CsvdD]6}|j|d��&t�|dg�}|�|jd�|�|gd�|�|ddgd�Wd�n1s3wYqdS)N)�-f�
--fromfilerrr�-s�don't go together)rrrr�fromfilerr*rrr�
test_fromfile�s���zParseArgsTestCase.test_fromfilec	Cr3)N)z-x�	--excluder)rrrr#�excluder*rrr�test_exclude�r6zParseArgsTestCase.test_excludec	CsddD]-}|j|d��t�|g�}|�|j�|�|ddgd�Wd�n1s*wYqdS)N)rHz--singlerrFrrI)rrrr#Zsinglerr*rrr�test_single�s���zParseArgsTestCase.test_singlec	Cs�dD].}|j|d��t�|dg�}|�|jdg�|�|gd�Wd�n1s+wYq|�tjtj	�t
tj	d��}td|d�td|d�Wd�n1sVwYtj
�tj	�}t�d	d
d|g�}|�|jddg�dS)N)z-iz--ignorer�patternr�w�
matchfile1��file�
matchfile2�-m�match�--ignorefile)rrrrZignore_testsr�
addCleanupr�unlink�TESTFN�open�print�os�path�abspath�rrr �fp�filenamerrr�test_ignore�s&�����zParseArgsTestCase.test_ignorec	CsdD].}|j|d��t�|dg�}|�|jdg�|�|gd�Wd�n1s+wYqt�gd��}|�|jddg�|�tjtj	�t
tj	d��}td	|d
�td|d
�Wd�n1sfwYtj
�tj	�}t�dd
d|g�}|�|jgd��dS)N)rVz--matchrrPr)rV�pattern1rV�pattern2rerfrQrRrSrUrVrW�--matchfile)rWrRrU)rrrrZmatch_testsrrYrrZr[r\r]r^r_r`rarrr�
test_match�s*�����zParseArgsTestCase.test_matchc	Cs|dD]9}|j|d��)t�|dg�}|�|j�t�|dg�}|�|j�|�|gd�Wd�n1s6wYqdS)N)z-Gz
--failfastrr-r7z#-G/--failfast needs either -v or -W)rrrr#Zfailfastrr*rrr�
test_failfast�s���zParseArgsTestCase.test_failfastc	CsdD]�}|j|d��qt�|dg�}|�|jddg�t�|dg�}|�|jdg�ttj�}|�d�t�|dg�}|�|j|�|�|gd�|�|d	gd
�t�|dg�}|�|jttj�dg�t�|d
g�}|�|jd
g�Wd�n1s~wYqdS)N)�-uz--userzgui,networkZgui�networkzgui,none,networkzall,-guirrzinvalid resourcez
all,tzdataZtzdataZextralargefile)	rrrrZ
use_resources�listZ
ALL_RESOURCES�remover)rrr Zexpectedrrr�test_use�s*

����zParseArgsTestCase.test_usec	Cr')N)z-Mz
--memlimitrZ4Gr)rrrr�memlimitrr*rrr�
test_memlimit�r,zParseArgsTestCase.test_memlimitcCs:t�ddg�}|�|jtj�tjd��|�	dgd�dS)Nz	--testdirrr)
rrr�testdirr^r_�joinr�SAVEDCWDrrrrr�test_testdir�szParseArgsTestCase.test_testdirc	Cr3)N)z-Lz
--runleaksr)rrrr#Zrunleaksr*rrr�
test_runleaks�r6zParseArgsTestCase.test_runleaksc	Cs�dD]o}|j|d��_t�|dg�}|�|jd�t�|dg�}|�|jd�t�|dg�}|�|jd�t�|d	g�}|�|jd
�|�|gd�|�|dgd
�|�|dgd�|�|dgd�Wd�n1slwYqdS)N)z-R�--huntrleaksr�:)���
reflog.txtz6:)�ryrzz:3)rxr/rzz
6:3:leaks.log)r{r/z	leaks.logr�6z&needs 2 or 3 colon-separated argumentszfoo:zinvalid huntrleaks valuez6:foo)rrrr�
huntrleaksrr*rrr�test_huntrleaks�s&
����z!ParseArgsTestCase.test_huntrleaksc	Cs�dD]G}|j|d��7t�|dg�}|�|jd�|�|gd�|�|dgd�|�|ddgd	�|�|d
dgd	�Wd�n1sDwYqdS)N)z-jz--multiprocessr�2�rrrD�-TrI�0)rrrrZuse_mprr*rrr�test_multiprocesss���z#ParseArgsTestCase.test_multiprocessc	Cr3)N)r��
--coverager)rrrr#Ztracer*rrr�
test_coverager6zParseArgsTestCase.test_coveragec	CspdD]3}|j|d��#t�|dg�}|�|jtj�tj	d��|�
|gd�Wd�n1s0wYqdS)N)z-Dz
--coverdirrrr)rrrr�coverdirr^r_rrrrsrr*rrr�
test_coverdirs����zParseArgsTestCase.test_coverdirc	Cr3)N)z-Nz--nocoverdirr)rrrZassertIsNoner�r*rrr�test_nocoverdir$r6z!ParseArgsTestCase.test_nocoverdirc	CstdD]5}|j|d��%t�|dg�}|�|jd�|�|gd�|�|dgd�Wd�n1s2wYqdS)N)z-tz--thresholdrZ1000i�rrrD)rrrrZ	thresholdrr*rrr�test_threshold*s���z ParseArgsTestCase.test_thresholdc
Cs�dD]E}|j|d��5t�t����}t�|g�}Wd�n1s#wY|�|j�|�	�}|�
d|�Wd�n1sBwYqdS)N)�-nz--nowindowsrz)the --nowindows (-n) option is deprecated)r�
contextlib�redirect_stderr�io�StringIOrrr#Z	nowindowsr
r)rr�stderrr rrrr�test_nowindows2s����z ParseArgsTestCase.test_nowindowsc	Cr3)N)z-F�	--foreverr)rrrr#�foreverr*rrr�test_forever;r6zParseArgsTestCase.test_forevercC�|�dgd�dS)Nz--xxxzusage:�r�rrrr�test_unrecognized_argumentAsz,ParseArgsTestCase.test_unrecognized_argumentcCs*t�dg�}|�|j�|�|jd�dS)Nz--quir)rrr#r;rr1rrrr�test_long_option__partialDsz+ParseArgsTestCase.test_long_option__partialcCs8t�ddg�}|�|j�|�|jd�|�|j�dS)Nr:rLr)rrr#r;rr1rMrrrr�test_two_optionsIsz"ParseArgsTestCase.test_two_optionscCs t�ddg�}|�|jd�dS)Nr(�)rrrr)rrrr�#test_option_with_empty_string_valueOsz5ParseArgsTestCase.test_option_with_empty_string_valuecCs t�dg�}|�|jdg�dS)Nr)rrrrrrrr�test_argSszParseArgsTestCase.test_argcCs<t�ddg�}|�|j�|�|jd�|�|jdg�dS)Nr:rr)rrr#r;rr1rrrrr�test_option_and_argWsz%ParseArgsTestCase.test_option_and_argcCs2t�gd��}|�|jd�|�|jddg�dS)N)�test_unaryopr-�
test_binopr.r�r�)rrrr1rrrrr�test_arg_option_arg]sz%ParseArgsTestCase.test_arg_option_argcCr�)Nz--unknown-optionz(unrecognized arguments: --unknown-optionr�r�rrr�test_unknown_optionbs�z%ParseArgsTestCase.test_unknown_optionN),�__name__�
__module__�__qualname__�__doc__rrr!r%r&r+r2r5r8r<r>r@rCrErKrNrOrdrhrirnrprtrur~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr)sT	
	rc	@sxeZdZdZdZdZdd�Zddd�Zd	d
�Zdd�Z	d
d�Z
ddddiddddf	dd�Zdd�Zddd�Z
dd�ZdS)�BaseTestCaser.Ztest_regrtest_ztest_[a-zA-Z0-9_]+cCs4tj�tj�t��|_t��|_|�	t
j|j�dSr)r^r_�realpath�dirname�__file__rq�tempfile�mkdtemp�
tmptestdirrYr�rmtreer�rrr�setUpls
zBaseTestCase.setUpNc
Cs�|sdtj}tjd7_|durt�d�}|j|}tj�|j|d�}|�	t
j|�z!t|ddd��}|�
|�Wd�W|S1sGwYW|Styh}zt��sc|�d||f��d}~ww)	Nznoop%sr.z�
                    import unittest

                    class Tests(unittest.TestCase):
                        def test_empty_test(self):
                            pass
                z.py�xzutf-8)�encodingzcannot write %s: %s)r��TEST_UNIQUE_ID�textwrap�dedent�TESTNAME_PREFIXr^r_rrr�rYrrZr\�write�PermissionError�	sysconfig�is_python_build�skipTest)r�name�coder_rb�excrrr�create_testrs*



�����zBaseTestCase.create_testcCs*t�||tj�}|s|�d||f�|S)Nz%r not found in %r)�re�search�	MULTILINE�fail)r�regex�outputrWrrr�regex_search�szBaseTestCase.regex_searchcCs"t�d|tj�}|�||�dS)N�^)r��compiler��assertRegex�rr�r�rrr�
check_line�szBaseTestCase.check_linecCs0dt|jf}t�||tj�}tdd�|D��S)Nz"^%s\[ *[0-9]+(?:/ *[0-9]+)*\] (%s)css�|]}|�d�VqdS)r.N��group��.0rWrrr�	<genexpr>�s�z4BaseTestCase.parse_executed_tests.<locals>.<genexpr>)�
LOG_PREFIX�TESTNAME_REGEXr��finditerr�rl)rr�r��parserrrr�parse_executed_tests�s
�z!BaseTestCase.parse_executed_testsrFcs�t|t�r|g}t|t�r|g}t|t�r|g}t|t�r |g}t|t�r(|g}t|t�r0|g}|�|�}|	rC|�t|�t|�|�n|�|||�dd���fdd�}
|ra|
d|�}|�||�|rn|
d|�}|�||�|r{|
d|�}|�||�|r�|
d|�}|�||�|r�|
d	|���}|�||�td
}|�||�|��D]\}}td|�d|�d
�}|�||�q�|r�|
d|�}|�||�t	|�t	|�t	|�t	|�t	|�t	|�}|r�d|�|�f}|s�|s�|dkr�d|}|�||�|
�r|�|d�g}|�r|�
d�n|�r|�r|�
d�|
�r#|�
d�t||||
|||f��s5|�
d�n|�s=|�
d�d�|�}|�rO|�|d�d|}|�|d|�dS)NcSs|dkrdSdS)Nr.�sr�r)�countrrr�plural�sz1BaseTestCase.check_executed_tests.<locals>.pluralcs6t|�}d�t|��}||�|�f}d||f}|S)N� z%s:\n    %s$)�lenrr�sorted)Zline_format�testsr��namesr��r�rr�
list_regex�s
z5BaseTestCase.check_executed_tests.<locals>.list_regexz%s test%s skippedz%s test%s failedz+%s test%s altered the execution environmentz%s test%s omittedz%s re-run test%sz'Re-running failed tests in verbose modezRe-running z in verbose mode \(matching: z\)z%s test%s run no testsz%s test%s OK\.$r.zAll %sz(Test suite interrupted by signal SIGINT.�FAILUREzENV CHANGEDZINTERRUPTEDzNO TEST RUN�SUCCESS�, zTests result: FAILUREzFAILURE then %szTests result: %s)
�
isinstance�strr�r�setr��keysr��itemsr��append�anyrr)rr�r��skipped�failed�env_changed�omitted�rerun�no_test_ranrB�interrupted�fail_env_changedZexecutedr�r�r�rWZgood�resultrr�r�check_executed_tests�s�








�

���

�

z!BaseTestCase.check_executed_testscCs>|�d|�}t|�d��}|�d|kodkn|�|S)NzUsing random seed ([0-9]+)r.ri���)r��intr�r#)rr�rW�randseedrrr�parse_random_seed�s zBaseTestCase.parse_random_seedrcKsx|sd}d|vr
tj|d<tj|fd|tjd�|��}|j|kr:dt|�|j|jf}|jr5|d|j7}|�|�|S)Nr�r�T)�universal_newlines�input�stdoutz8Command %s failed with exit code %s

stdout:
---
%s
---
z
stderr:
---
%s---
)	�
subprocess�STDOUT�run�PIPE�
returncoder�r�r�r�)rrr��exitcode�kw�procrrrr�run_commands*
��
��
zBaseTestCase.run_commandcKs*tjdddg|�}|j|fi|��}|jS)Nz-X�faulthandlerz-I)�sys�
executablerr�)rrr�r�rrr�
run_python szBaseTestCase.run_python)NN)Nr)r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr�gs$

�^
r�c@�eZdZdd�ZdS)�CheckActualTestscCstgd�}|�|�}t|���}tj�t�tj�t	��d�}tt�|��}|j
||dddd�|�����d�dS)	zP
        Check that regrtest appears to find the expected set of tests.
        )�-Wd�-E�-bbrV�
test.regrtest�--list-testsztest*.py�	�
z+Unexpectedly low number of tests found in:
r�)rN)rr��
splitlinesr^r_rr�glob�escaper�r�Z
assertGreater)rrr�Zrough_number_of_tests_foundZactual_testsuite_globZrough_counted_test_py_filesrrr�#test_finds_expected_number_of_tests's
�
�
�z4CheckActualTests.test_finds_expected_number_of_testsN)r�r�r�rrrrrr&�rcs�eZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
e�e��d�dd��Zdd�Ze�e��d�e�ejdkd�dd���Ze�ejdkd�dd ��Z�ZS)!�ProgramsTestCasezp
    Test various ways to run the Python test suite. Use options close
    to options used on the buildbot.
    rycsjt����fdd�t�j�D��_gd��_ddd�jg�_�j�d�t	j
dkr3�j�d	�dSdS)
Nc�g|]}����qSr�r��r��indexr�rr�
<listcomp>J�z*ProgramsTestCase.setUp.<locals>.<listcomp>)rrr	z-uallz-rwW�--testdir=%s)rZ3600z-j4�win32r�)�superr��range�NTESTr��python_argsr��
regrtest_args�extendr�platformr�r���	__class__r�rr�Fs

�
�zProgramsTestCase.setUpcCs |�|�|j||jdd�dS)NT)rB)r�r�r�)rr�rrr�check_outputSs
zProgramsTestCase.check_outputcCs|�|�}|�|�dSr)rr%)rrr�rrr�	run_testsWs
zProgramsTestCase.run_testscC�8tj�|jd�}g|j�|�|j�|j�}|�|�dS)Nzregrtest.py�r^r_rrrqrr r�r&�r�scriptrrrr�test_script_regrtest[sz%ProgramsTestCase.test_script_regrtestcC�,g|j�d�d�|j�|j�}|�|�dS)NrV�test�rr r�r&�rrrrr�test_module_testb���z!ProgramsTestCase.test_module_testcCr,)NrVr
r.r/rrr�test_module_regrtesthr1z%ProgramsTestCase.test_module_regrtestcCr,)NrVz
test.autotestr.r/rrr�test_module_autotestnr1z%ProgramsTestCase.test_module_autotestcCs0d}g|j�d�|�|j�|j�}|�|�dS)Nzfrom test import autotestz-cr.)rr�rrrr�test_module_from_test_autotestts��z/ProgramsTestCase.test_module_from_test_autotestcCr')Nzautotest.pyr(r)rrr�test_script_autotest{sz%ProgramsTestCase.test_script_autotestz$run_tests.py script is not installedcCs2tj�tddd�}|g|j�|j�}|�|�dS)N�ToolsZscriptszrun_tests.py)r^r_rr�ROOT_DIRr r�r&r)rrr�test_tools_script_run_tests�sz,ProgramsTestCase.test_tools_script_run_testscGs|�|�}|�|j�dSr)rr%r�)rrr�rrr�	run_batch�s
zProgramsTestCase.run_batchz test.bat script is not installedrzWindows onlycCs�tj�tddd�}d|jg}t��dkr|�d�nt��dkr'|�d�n
t��d	d
kr4|�d�t	s;|�d�|j
|g|�|j�R�dS)
Nr6Zbuildbotztest.batr�ARM64�-arm64�ARM�-arm32r�64bit�-x64z+d)r^r_rrr7r�r"�machiner��architecture�Py_DEBUGr9r�)rr*Z	test_argsrrr�test_tools_buildbot_test�s

z)ProgramsTestCase.test_tools_buildbot_testcCs�tj�td�}tj�|�s|�d|�d��dg}t��dkr%|�d�nt��dkr1|�d�n
t�	�d	d
kr>|�d�t
rE|�d�|j|g|�|j�|j
�R�dS)
NzPCbuild\rt.batzFile "z" does not existr9r:r;r<r=rr>r?z-d)r^r_rrr7�isfiler�r"r@r�rArBr9r r�)rr*Zrt_argsrrr�test_pcbuild_rt�s

"z ProgramsTestCase.test_pcbuild_rt)r�r�r�r�rr�r%r&r+r0r2r3r4r5�unittest�
skipUnlessr�r�r8r9rr"rCrE�
__classcell__rrr#rr>s0

�

�rc@s<eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Ze�ed�dd��Ze�ed�dd��Zdd �Zd!d"�Zejd#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z d3d4�Z!d5d6�Z"d7d8�Z#ejd9d:��Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dCdD�Z)dES)F�ArgsTestCasez2
    Test arguments of the Python test suite.
    cOs&ddd|jg|�}|j|fi|��S)NrVr-r)r�r)rZtestargsr��cmdargsrrrr&�szArgsTestCase.run_testscCsNt�d�}|�d�}|jd|d�}||g}|j|ddi�}|j|||d�dS)Nz�
            import unittest

            class FailingTest(unittest.TestCase):
                def test_failing(self):
                    self.fail("bug")
        �okZfailing�r�r�r��r��r�r�r�r&r�)rr�Ztest_okZtest_failingr�r�rrr�test_failing_test�s

zArgsTestCase.test_failing_testcCs�i}dD]}t�d|�}|�||�||<qt|���}|jddg|�R�}|�||�|jdg|�R�}|j|||dd�|j|�}|j|||d�dS)N)Zaudiorka
                        from test import support; support.requires(%r)
                        import unittest
                        class PassingTest(unittest.TestCase):
                            def test_pass(self):
                                pass
                    rj�allz-uaudiork)r�)r�r�r�r��valuesr&r�)rr�Zresourcer�Z
test_namesr�rrr�test_resources�s"��

�zArgsTestCase.test_resourcesc	Cs�t�d�}|�d|�}|�d|�}|�|�}|�d|�}t|�d��}|�dd||�}|�|�}|�||�|�d|�}t|�d��}|�||�dS)Nza
            import random
            print("TESTRANDOM: %s" % random.randint(1, 1000))
        �randomrAzTESTRANDOM: ([0-9]+)r.z
--randseed=%s)	r�r�r�r&r�r�r�r�r)	rr�r-r�r�rW�test_randomZ	randseed2Ztest_random2rrrrT�s


zArgsTestCase.test_randomc	s��fdd�td�D�}tj}��tj|�t|d��.}d}t|d�D]\}}d||t|�|f}|r8|d|7}t||d�|}q"Wd�n1sKwY��	d	|�}��
||�t|d��}t|d�D]\}}td
|t|�|f|d�qgWd�n1s�wY��	d	|�}��
||�t|d��}|D]}t||d�q�Wd�n1s�wY��	d	|�}��
||�t|d��}|D]
}td||d�q�Wd�n1s�wY��	d	|�}��
||�dS)Ncrrrrr�rrr�rz.ArgsTestCase.test_fromfile.<locals>.<listcomp>rxrQr.z00:00:%02i [%s/%s] %sz -- %s took 0 secrSrGz
[%s/%s] %szLib/test/%s.py)rrr[rYrZr\�	enumerater�r]r&r�)	rr�rcrbZpreviousrr��liner�rr�rrK�sL���
������zArgsTestCase.test_fromfilecCs6t}|jd|d�}|j|dd�}|j|||dd�dS)N�sigintrL��r�T�r�r�)�TEST_INTERRUPTEDr�r&r��rr�r-r�rrr�test_interrupted-s

�zArgsTestCase.test_interruptedcsV�fdd�td�D�}�jdg|�R�}��||�d�jt|�f}��||�dS)Ncrrrrr�rrr6rz-ArgsTestCase.test_slowest.<locals>.<listcomp>r/r=z#10 slowest tests:
(?:- %s: .*
){%s})rr&r�r�r�r�)rr�r�r�rr�rr>4s�zArgsTestCase.test_slowestc	Cs�t}|jd|d�}dD]=}|j|d��-|rdd|f}nd|f}|j|ddi�}|j|||d	d
�d}|�||�Wd�n1sCwYqdS)NrWrL)FT)�multiprocessingr=�-j2r�rXTrZz10 slowest tests:
)r[r�rr&r�r�)rr�r-r^rr�r�rrr�test_slowest_interrupted>s ����z%ArgsTestCase.test_slowest_interruptedcCs8|�d�}|�d|�}|�||g�d}|�||�dS)NZcoverager�zLlines +cov% +module +\(path\)\n(?: *[0-9]+ *[0-9]{1,2}% *[^ ]+ +\([^)]+\)+)+)r�r&r�r�)rr-r�r�rrrr�Ps

zArgsTestCase.test_coveragecCs*|�d�}|jd|dd�}|�|d�dS)Nr$r"�key)r�zPress any key to continue)r�r&r�)rr-r�rrrr%Ys
zArgsTestCase.test_waitcCsBt�d�}|jd|d�}|jd|dd�}|j||gd|d�dS)	NaL
            import builtins
            import unittest

            class ForeverTester(unittest.TestCase):
                def test_run(self):
                    # Store the state in the builtins module, because the test
                    # module is reload at each run
                    if 'RUN' in builtins.__dict__:
                        builtins.__dict__['RUN'] += 1
                        if builtins.__dict__['RUN'] >= 3:
                            self.fail("fail at the 3rd runs")
                    else:
                        builtins.__dict__['RUN'] = 1
        r�rLr�r�rYr/rMrNr\rrrr�_s
zArgsTestCase.test_foreverc
Cs�|jd|d�}d}|�tj|�|jdd|dtjd�}|j||g|d�d	}|�|t	�
|��d
||f}|�||�t|��}|�
�}	|�||	�Wd�dS1sUwYdS)Nr}rLrzrvz3:3:r�)r�r�rMz&beginning 6 repetitions
123456
......
z%s leaked [1, 1, 1] %s, sum=3
)r�rYrrZr&r�r�r�r�r�rrr\�read)
rr�Zwhatr-rcr�rVZline2rbZreflogrrr�
check_leakts 
�
"�zArgsTestCase.check_leakzneed a debug buildcC�t�d�}|�|d�dS)Nz�
            import unittest

            GLOBAL_LIST = []

            class RefLeakTest(unittest.TestCase):
                def test_leak(self):
                    GLOBAL_LIST.append(object())
        Z
references�r�r�rc�rr�rrrr~��
	zArgsTestCase.test_huntrleakscCrd)Na
            import os
            import unittest

            class FDLeakTest(unittest.TestCase):
                def test_leak(self):
                    fd = os.open(__file__, os.O_RDONLY)
                    # bug: never close the file descriptor
        zfile descriptorsrerfrrr�test_huntrleaks_fd_leak�rgz$ArgsTestCase.test_huntrleaks_fd_leakcs@�fdd�td�D�}�jdg|�R�}��|����|�dS)Ncrrr)r��ir�rrr�rz0ArgsTestCase.test_list_tests.<locals>.<listcomp>rxr)rr&r�rstripr)rr�r�rr�r�test_list_tests�s
�zArgsTestCase.test_list_testscCspt�d�}|j|d�}d|d|g}|�d|�}|�|��|�d|g}|�ddd|�}|�|��|�dS)Nz�
            import unittest

            class Tests(unittest.TestCase):
                def test_method1(self):
                    pass
                def test_method2(self):
                    pass
        rLz%s.Tests.test_method1z%s.Tests.test_method2z--list-casesrV�test_method1)r�r�r�r&rr)rr��testname�all_methodsr�rrr�test_list_cases�s
	�
�zArgsTestCase.test_list_casescCsFd}|jd|d�}|g}|jdg|�Rddi�}|j|||dd�dS)	Nz,import faulthandler; faulthandler._sigsegv()Zcrash)r�r�r_r�r�T)r�rB)r�r&r�)rr�Z
crash_testr�r�rrr�test_crashed�s

�zArgsTestCase.test_crashedcCs$tjdtjd�}dd�|�|�D�S)Nz^(test[^ ]+).*ok$)�flagscSsg|]}|�d��qS)r.r�r�rrrr�sz.ArgsTestCase.parse_methods.<locals>.<listcomp>)r�r�r�r�r�rrr�
parse_methods�szArgsTestCase.parse_methodsc
Cs�t�d�}gd�}|j|d�}tj}|�tj|�dd|g}t|d��}|D]}t||d�q'Wd�n1s:wY|�	dd	||�}|�
|�}	d
dg}|�|	|�dS)N�V
            import unittest

            class Tests(unittest.TestCase):
                def test_method1(self):
                    pass
                def test_method2(self):
                    pass
                def test_method3(self):
                    pass
                def test_method4(self):
                    pass
        �rl�test_method2�test_method3�test_method4rLrl�%s.Tests.test_method3rQrSr-rXrurw)r�r�r�rr[rYrZr\r]r&rrr)
rr�rnrmrc�subsetrbr�r��methodsrrr�test_ignorefile�s"

���
zArgsTestCase.test_ignorefilec
Cs�t�d�}gd�}|j|d�}|�d|�}|�|�}|�||�tj}|�tj	|�dd|g}t
|d��}|D]}	t|	|d�q8Wd�n1sKwY|�dd	||�}|�|�}dd
g}|�||�dS)NrsrtrLr-rlrxrQrSrgrv)r�r�r�r&rrrrr[rYrZr\r])
rr�rnrmr�rzrcryrbr�rrr�test_matchfile�s(


���
zArgsTestCase.test_matchfilecCsZt�d�}|j|d�}|�|�}|j||g|d�|jd|dd�}|j||g|dd�dS)	Nz�
            import unittest

            class Tests(unittest.TestCase):
                def test_env_changed(self):
                    open("env_changed", "w").close()
        rL)r��--fail-env-changedr/rYT�r�r�rN�rr�rmr�rrr�test_env_changed!s


�zArgsTestCase.test_env_changedcCsBt�d�}|j|d�}|jd|dd�}|j||g||did�dS)Na
            import unittest

            class Tests(unittest.TestCase):
                def test_succeed(self):
                    return

                def test_fail_always(self):
                    # test that always fails
                    self.fail("bug")
        rLr4r�rYZtest_fail_always)r�r�rNrrrr�test_rerun_fail4s


�zArgsTestCase.test_rerun_failcCs@t�d�}|j|d�}|jd|dd�}|j||g|did�dS)Nax
            import builtins
            import unittest

            class Tests(unittest.TestCase):
                def test_succeed(self):
                    return

                def test_fail_once(self):
                    if not hasattr(builtins, '_test_failed'):
                        builtins._test_failed = True
                        self.fail("bug")
        rLr4rrYZtest_fail_once)r�rNrrrr�test_rerun_successGs



�zArgsTestCase.test_rerun_successcCs>t�d�}|j|d�}|j|dddd�}|j||g|d�dS�N��
            import unittest

            class Tests(unittest.TestCase):
                def test_bug(self):
                    pass
        rLrV�
nosuchtestrrY�r�rNrrrr�test_no_tests_ran\s
zArgsTestCase.test_no_tests_rancCs6t�d�}|j|d�}|j|dd�}|�||g�dS)Nz�
            import unittest

            class Tests(unittest.TestCase):
                def test_skipped(self):
                    self.skipTest("because")
        rLrrYrNrrrr�test_no_tests_ran_skipis
z#ArgsTestCase.test_no_tests_ran_skipcCsRt�d�}|j|d�}|j|d�}|j||dddd�}|j|||g||gd�dSr�rN)rr�rm�	testname2r�rrr�,test_no_tests_ran_multiple_tests_nonexistentvs

�z9ArgsTestCase.test_no_tests_ran_multiple_tests_nonexistentc	Cs^t�d�}|j|d�}t�d�}|j|d�}|j||dddddd�}|j|||g|gd	�dS)
Nr�rLz�
            import unittest

            class Tests(unittest.TestCase):
                def test_other_bug(self):
                    pass
        rVr�Ztest_other_bugrrYr�rN)rr�rmZ
other_coder�r�rrr�)test_no_test_ran_some_test_exist_some_not�s

�
�z6ArgsTestCase.test_no_test_ran_some_test_exist_some_notcCsft�d�}|j|d�}|jd|dd�}|j||g|gdd�|jd|dd�}|j||g|gdd�dS)	Na�
            import _testcapi
            import gc
            import unittest

            @_testcapi.with_tp_del
            class Garbage:
                def __tp_del__(self):
                    pass

            class Tests(unittest.TestCase):
                def test_garbage(self):
                    # create an uncollectable object
                    obj = Garbage()
                    obj.ref_cycle = obj
                    obj = None
        rLr}r/rYTr~z--findleaksrNrrrr�test_findleaks�s

�

�zArgsTestCase.test_findleakscCsXt�d�}|j|d�}|jdd|dd�}|j||g|d�|�|t�d|tj��dS)	Naa
            import time
            import unittest
            try:
                import faulthandler
            except ImportError:
                faulthandler = None

            class Tests(unittest.TestCase):
                # test hangs and so should be stopped by the timeout
                def test_sleep(self):
                    # we want to test regrtest multiprocessing timeout,
                    # not faulthandler timeout
                    if faulthandler is not None:
                        faulthandler.cancel_dump_traceback_later()

                    time.sleep(60 * 5)
        rLr_z
--timeout=1.0r�rYrMz%s timed out)	r�r�r�r&r�r�r�r�r�rrrr�test_multiprocessing_timeout�s

��z)ArgsTestCase.test_multiprocessing_timeoutcC�Zt�d�}|j|d�}|jdd|dd�}|j||g|gdd�|�d	|�|�d
|�dS)Na�
            import unittest
            import weakref
            from test.support import captured_stderr

            class MyObject:
                pass

            def weakref_callback(obj):
                raise Exception("weakref callback bug")

            class Tests(unittest.TestCase):
                def test_unraisable_exc(self):
                    obj = MyObject()
                    ref = weakref.ref(obj, weakref_callback)
                    with captured_stderr() as stderr:
                        # call weakref_callback() which logs
                        # an unraisable exception
                        obj = None
                    self.assertEqual(stderr.getvalue(), '')
        rLr}r-r/rYTr~zWarning -- Unraisable exceptionzException: weakref callback bug�r�r�r�r&r�rrrrr�test_unraisable_exc�s

�z ArgsTestCase.test_unraisable_exccCr�)Na[
            import threading
            import unittest
            from test.support import captured_stderr

            class MyObject:
                pass

            def func_bug():
                raise Exception("bug in thread")

            class Tests(unittest.TestCase):
                def test_threading_excepthook(self):
                    with captured_stderr() as stderr:
                        thread = threading.Thread(target=func_bug)
                        thread.start()
                        thread.join()
                    self.assertEqual(stderr.getvalue(), '')
        rLr}r-r/rYTr~z$Warning -- Uncaught thread exceptionzException: bug in threadr�rrrr�test_threading_excepthook�s

�z&ArgsTestCase.test_threading_excepthookcCs<tj�tj�}|�|tj�d��|��r|�d�dSdS)Nz not setzModified guard)r^�environ�getrZUNICODE_GUARD_ENVZassertIsNotNone�isasciir�)r�guardrrr�test_unicode_guard_envs
�z#ArgsTestCase.test_unicode_guard_envcCs~tj�|jd�}t�|�tj�|jd�}t|d���||g}ddd|jdg}|�|�|D]}|�tj�	|�|�q0dS)NZtest_python_123Ztest_python_456�wbrVr-z--tempdir=%sz	--cleanup)
r^r_rrr��mkdirr\�closerZassertFalse�exists)rr�rcr�rJr�rrr�test_cleanups
�
�zArgsTestCase.test_cleanupN)*r�r�r�r�r&rOrRrTrKr]r>r`r�r%r�rcrFrGrBr~rhrkrorZcpython_onlyrprrr{r|r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrI�sN0
	






$)


!rIc@r)�	TestUtilscCs�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d	�d
�|�t�d�d�|�t�d
�d�|�t�d�d�|�t�d�d�|�t�d�d�dS)Nrz0 msg��&�.>z1 msg{�G�z�?z10 msg�?z1.5 secr.z1.0 sec�xz2 min�yz2 min 1 seci0*z3 houri�*z3 hour 2 mini1*z3 hour 1 sec)rrZformat_durationr�rrr�test_format_duration0s<����������zTestUtils.test_format_durationN)r�r�r�r�rrrrr�/rr��__main__),r�r�rr�Zos.pathr^r"r�r�rr�r�r��timerFr-rrZtest.supportrZtest.libregrtestrr�hasattrrBr_rrr�r�r7r`�normpathr�r�r[ZTestCaserr�rrrIr�r��mainrrrr�<module>sP


@@r�