Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_regrtest.cpython-311.opt-1.pyc
�

�Ke=�����dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZddlmZddlmZmZejsejd���ee	d��Zej�ej�e��d	d	��Zej� ej�!e����Zd
Z"ej#d��Z$Gd�d
ej%��Z&Gd�dej%��Z'Gd�de'��Z(Gd�de'��Z)Gd�de'��Z*Gd�dej%��Z+e,dkrej-��dSdS)zM
Tests of regrtest.py.

Note: test_regrtest cannot be run twice in parallel.
�N)�libregrtest)�support)�	os_helper)�utils�setupztest module requires subprocess�gettotalrefcountz..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��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�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&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*S)+�ParseArgsTestCasezC
    Test regrtest's argument parsing, function _parse_args().
    c�8�tj��5}|�t��5t	j|��ddd��n#1swxYwYddd��n#1swxYwY|�||�����dS�N)r�captured_stderr�assertRaises�
SystemExitr�_parse_args�assertIn�getvalue)�self�args�msg�errs    �</usr/local/apps/python3/lib/python3.11/test/test_regrtest.py�
checkErrorzParseArgsTestCase.checkError0s���
�
$�
&�
&�	*�#�t�/@�/@��/L�/L�	*�	*��#�D�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*��
�
�c�3�<�<�>�>�*�*�*�*�*s4�A'�A�A'�A	�A'�A	�A'�'A+�.A+c	��dD]�}|�|���5tj��5}|�t��5tj|g��ddd��n#1swxYwYddd��n#1swxYwY|�d|�����ddd��n#1swxYwY��dS)N)z-hz--help��optzRun Python regression tests.)	�subTestr�captured_stdoutrrrrrr)rr�outs   r�	test_helpzParseArgsTestCase.test_help5s���!�	N�	N�C����#��&�&�
N�
N��,�.�.�3�#��&�&�z�2�2�3�3��+�S�E�2�2�2�3�3�3�3�3�3�3�3�3�3�3����3�3�3�3�3�3�3�3�3�3�3�3�3�3�3����3�3�3�3��
�
�<�c�l�l�n�n�M�M�M�	
N�
N�
N�
N�
N�
N�
N�
N�
N�
N�
N����
N�
N�
N�
N��	N�	NsX�C�B�
A,	� B�,A0
�0B�3A0
�4B�7C�B�C�
B�+C�C	�	C	c���tjddg��}|�|jd��|�dgd��|�ddgd��dS)N�	--timeoutz4.2g������@�expected one argument�foozinvalid float value)rr�assertEqual�timeoutr�r�nss  r�test_timeoutzParseArgsTestCase.test_timeout=sf��
�
$�k�5�%9�
:�
:�������S�)�)�)�����
�'>�?�?�?�����e�,�.C�D�D�D�D�D�c�d�tjdg��}|�|j��dS)N�--wait)rr�
assertTrue�waitr&s  r�	test_waitzParseArgsTestCase.test_waitCs.��
�
$�h�Z�
0�
0������� � � � � r)c��tjddg��}|�|jd��|�dgd��dS)Nz
--worker-argsz[[], {}]r")rrr$�worker_argsrr&s  r�test_worker_argsz"ParseArgsTestCase.test_worker_argsGsM��
�
$�o�z�%B�
C�
C��������4�4�4�����)�+B�C�C�C�C�Cr)c��dD]x}|�|���5tj|dg��}|�|jd��|�|gd��ddd��n#1swxYwY�ydS)N)z-S�--startrr#r")rrrr$�startr�rrr's   r�
test_startzParseArgsTestCase.test_startLs���"�	@�	@�C����#��&�&�
@�
@� �,�c�5�\�:�:��� � ���5�1�1�1������'>�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@��	@�	@��A	A0�0A4	�7A4	c���tjdg��}|�|jd��tjdg��}|�|jd��tjdg��}|�|jd��tjdgdz��}|�|jd��tjg��}|�|jd��dS)N�-v�z-vvv��	--verboser)rrr$�verboser&s  r�test_verbosezParseArgsTestCase.test_verboseSs���
�
$�d�V�
,�
,�������Q�'�'�'�
�
$�f�X�
.�
.�������Q�'�'�'�
�
$�k�]�
3�
3�������Q�'�'�'�
�
$�k�]�Q�%6�
7�
7�������Q�'�'�'�
�
$�R�
(�
(�������Q�'�'�'�'�'r)c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)�-wz
--verbose2r)rrrr,�verbose2r5s   r�
test_verbose2zParseArgsTestCase.test_verbose2_���%�	-�	-�C����#��&�&�
-�
-� �,�c�U�3�3�������,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-��	-�	-��0A�A	�A	c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)�-Wz
--verbose3r)rrrr,�verbose3r5s   r�
test_verbose3zParseArgsTestCase.test_verbose3erCrDc��dD]z}|�|���5tj|g��}|�|j��|�|jd��ddd��n#1swxYwY�{dS)N)�-q�--quietrr)rrrr,�quietr$r=r5s   r�
test_quietzParseArgsTestCase.test_quietks���"�	0�	0�C����#��&�&�
0�
0� �,�c�U�3�3�������)�)�)�� � ���Q�/�/�/�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0��	0�	0s�AA2�2A6	�9A6	c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)z-o�	--slowestr)rrrr,�
print_slowr5s   r�test_slowestzParseArgsTestCase.test_slowestrs���$�	/�	/�C����#��&�&�
/�
/� �,�c�U�3�3������
�.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��	/�	/rDc���tjdg��}|�|j��tjdg��}|�|j��dS)Nz--headerr<)rrr,�headerr&s  r�test_headerzParseArgsTestCase.test_headerxsT��
�
$�j�\�
2�
2������	�"�"�"�
�
$�k�]�
3�
3������	�"�"�"�"�"r)c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)�-rz--randomizer)rrrr,�	randomizer5s   r�test_randomizez ParseArgsTestCase.test_randomizes���&�	.�	.�C����#��&�&�
.�
.� �,�c�U�3�3�������-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.��	.�	.rDc��tjddg��}|�|jd��|�|j��|�dgd��|�ddgd��dS)Nz
--randseed�12345i90r"r#�invalid int value)rrr$�random_seedr,rWrr&s  r�
test_randseedzParseArgsTestCase.test_randseed�sz��
�
$�l�G�%<�
=�
=��������/�/�/������%�%�%������(?�@�@�@�����u�-�/B�C�C�C�C�Cr)c�.�dD]�}|�|���5tj|dg��}|�|jd��|�|gd��|�|ddgd��ddd��n#1swxYwY��dS)N)�-f�
--fromfilerr#r"�-s�don't go together)rrrr$�fromfilerr5s   r�
test_fromfilezParseArgsTestCase.test_fromfile�s���%�	I�	I�C����#��&�&�
I�
I� �,�c�5�\�:�:��� � ���e�4�4�4������'>�?�?�?�����e�T� 2�4G�H�H�H�	
I�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I����
I�
I�
I�
I��	I�	Is�A"B	�	B
	�B
	c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)z-x�	--excluder)rrrr,�excluder5s   r�test_excludezParseArgsTestCase.test_exclude����$�	,�	,�C����#��&�&�
,�
,� �,�c�U�3�3������
�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,��	,�	,rDc��dD]x}|�|���5tj|g��}|�|j��|�|ddgd��ddd��n#1swxYwY�ydS)N)raz--singlerr_r#rb)rrrr,�singlerr5s   r�test_singlezParseArgsTestCase.test_single�s���#�	I�	I�C����#��&�&�
I�
I� �,�c�U�3�3������	�*�*�*�����d�E� 2�4G�H�H�H�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I�
I����
I�
I�
I�
I��	I�	Ir7c��dD]y}|�|���5tj|dg��}|�|jdg��|�|gd��ddd��n#1swxYwY�z|�tjtj	��ttj	d��5}td|���td|���ddd��n#1swxYwYtj
�tj	��}tjd	d
d|g��}|�|jddg��dS)N)z-iz--ignorer�patternr"�w�
matchfile1��file�
matchfile2�-m�match�--ignorefile)rrrr$�ignore_testsr�
addCleanupr�unlink�TESTFN�open�print�os�path�abspath�rrr'�fp�filenames     r�test_ignorezParseArgsTestCase.test_ignore�s���#�	@�	@�C����#��&�&�
@�
@� �,�c�9�-=�>�>��� � ���9�+�>�>�>������'>�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@��
	
���	�(�)�*:�;�;�;�
�)�"�C�
(�
(�	)�B��,�R�(�(�(�(��,�R�(�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)��7�?�?�9�#3�4�4��
�
$�d�G�&4�h�&@�A�A�������&��5�	7�	7�	7�	7�	7s$�A
A1�1A5	�8A5	�#C0�0C4�7C4c��dD]y}|�|���5tj|dg��}|�|jdg��|�|gd��ddd��n#1swxYwY�ztjgd���}|�|jddg��|�tjtj	��ttj	d��5}td	|�
��td|�
��ddd��n#1swxYwYtj
�tj	��}tjdd
d|g��}|�|jgd���dS)N)rtz--matchrrnr")rt�pattern1rt�pattern2r�r�rorprqrsrtru�--matchfile)rurprs)rrrr$�match_testsrrxrryrzr{r|r}r~rr�s     r�
test_matchzParseArgsTestCase.test_match�s'��"�	@�	@�C����#��&�&�
@�
@� �,�c�9�-=�>�>��� � ���)��=�=�=������'>�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@��
�
$�&8�&8�&8�9�9�������*�j�)A�B�B�B����	�(�)�*:�;�;�;�
�)�"�C�
(�
(�	)�B��,�R�(�(�(�(��,�R�(�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)��7�?�?�9�#3�4�4��
�
$�d�G�&3�X�&?�@�@�������>�>�>�	@�	@�	@�	@�	@s$�A
A1�1A5	�8A5	�4#D#�#D'�*D'c�Z�dD]�}|�|���5tj|dg��}|�|j��tj|dg��}|�|j��|�|gd��ddd��n#1swxYwY��dS)N)z-Gz
--failfastrr9rFz#-G/--failfast needs either -v or -W)rrrr,�failfastrr5s   r�
test_failfastzParseArgsTestCase.test_failfast�s��%�	N�	N�C����#��&�&�
N�
N� �,�c�4�[�9�9�������,�,�,� �,�c�4�[�9�9�������,�,�,������'L�M�M�M�
N�
N�
N�
N�
N�
N�
N�
N�
N�
N�
N����
N�
N�
N�
N��	N�	Ns�A8B�B#	�&B#	c�R�dD�]�}|�|���5tj|dg��}|�|jddg��tj|dg��}|�|jdg��ttj��}|�d��tj|dg��}|�|j|��|�|gd��|�|d	gd
��tj|dg��}|�|jttj��dgz��tj|d
g��}|�|jd
g��ddd��n#1swxYwY���dS)N)�-uz--userzgui,network�gui�networkzgui,none,networkzall,-guir"r#zinvalid resourcez
all,tzdata�tzdata�extralargefile)	rrrr$�
use_resources�list�
ALL_RESOURCES�remover)rrr'�expecteds    r�test_usezParseArgsTestCase.test_use�s��� �	G�	G�C����#��&�&�
G�
G� �,�c�=�-A�B�B��� � ��!1�E�9�3E�F�F�F� �,�c�3E�-F�G�G��� � ��!1�I�;�?�?�?��� 9�:�:������&�&�&� �,�c�:�->�?�?��� � ��!1�8�<�<�<������'>�?�?�?�����e��.@�A�A�A�!�,�c�<�-@�A�A��� � ��!1�!%�k�&?�!@�!@�H�:�!M�O�O�O�!�,�c�3C�-D�E�E��� � ��!1�4D�3E�F�F�F�+
G�
G�
G�
G�
G�
G�
G�
G�
G�
G�
G����
G�
G�
G�
G��	G�	Gs�E2F�F	�!F	c��dD]x}|�|���5tj|dg��}|�|jd��|�|gd��ddd��n#1swxYwY�ydS)N)z-Mz
--memlimitr�4Gr")rrrr$�memlimitrr5s   r�
test_memlimitzParseArgsTestCase.test_memlimit�s���%�	@�	@�C����#��&�&�
@�
@� �,�c�4�[�9�9��� � ���d�3�3�3������'>�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@��	@�	@r7c���tjddg��}|�|jtj�tjd����|�	dgd��dS)Nz	--testdirr#r")
rrr$�testdirr}r~�joinr�SAVEDCWDrr&s  r�test_testdirzParseArgsTestCase.test_testdir�s_��
�
$�k�5�%9�
:�
:�������R�W�\�\�)�2D�e�%L�%L�M�M�M�����
�'>�?�?�?�?�?r)c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)z-Lz
--runleaksr)rrrr,�runleaksr5s   r�
test_runleakszParseArgsTestCase.test_runleaks�rCrDc��dD�]T}|�|���5tj|dg��}|�|jd��tj|dg��}|�|jd��tj|dg��}|�|jd��tj|d	g��}|�|jd
��|�|gd��|�|dgd
��|�|dgd��|�|dgd��ddd��n#1swxYwY��VdS)N)z-R�--huntrleaksr�:)���
reflog.txtz6:)�r�r�z:3)r�r;r�z
6:3:leaks.log)r�r;z	leaks.logr"�6z&needs 2 or 3 colon-separated argumentszfoo:zinvalid huntrleaks valuez6:foo)rrrr$�
huntrleaksrr5s   r�test_huntrleaksz!ParseArgsTestCase.test_huntrleaks�s���'�	L�	L�C����#��&�&�

L�

L� �,�c�3�Z�8�8��� � ���0D�E�E�E� �,�c�4�[�9�9��� � ���0D�E�E�E� �,�c�4�[�9�9��� � ���0D�E�E�E� �,�c�?�-C�D�D��� � ���0C�D�D�D������'>�?�?�?�����c�
� H�J�J�J�����f�
�/I�J�J�J�����g��0J�K�K�K�

L�

L�

L�

L�

L�

L�

L�

L�

L�

L�

L����

L�

L�

L�

L��	L�	Ls�D$E�E	�E	c��dD]�}|�|���5tj|dg��}|�|jd��|�|gd��|�|dgd��|�|ddgd	��|�|d
dgd	��ddd��n#1swxYwY��dS)N)z-jz--multiprocessr�2�r"r#r[�-Trb�0)rrrr$�use_mprr5s   r�test_multiprocessz#ParseArgsTestCase.test_multiprocesss.��)�	G�	G�C����#��&�&�
G�
G� �,�c�3�Z�8�8��� � ���A�.�.�.������'>�?�?�?�����e��.A�B�B�B�����c�4� 0�2E�F�F�F�����c�4� 0�2E�F�F�F�

G�
G�
G�
G�
G�
G�
G�
G�
G�
G�
G����
G�
G�
G�
G��	G�	Gs�BB:�:B>	�B>	c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)r��
--coverager)rrrr,�tracer5s   r�
test_coveragezParseArgsTestCase.test_coverages���%�	*�	*�C����#��&�&�
*�
*� �,�c�U�3�3�������)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��	*�	*rDc	�L�dD]�}|�|���5tj|dg��}|�|jt
j�tj	d����|�
|gd��ddd��n#1swxYwY��dS)N)z-Dz
--coverdirrr#r")rrrr$�coverdirr}r~r�rr�rr5s   r�
test_coverdirzParseArgsTestCase.test_coverdirs���%�	@�	@�C����#��&�&�
@�
@� �,�c�5�\�:�:��� � ���!#����i�.@�%�!H�!H�J�J�J������'>�?�?�?�	
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@��	@�	@s�A1B�B	�B	c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)z-Nz--nocoverdirr)rrr�assertIsNoner�r5s   r�test_nocoverdirz!ParseArgsTestCase.test_nocoverdir&s���'�	/�	/�C����#��&�&�
/�
/� �,�c�U�3�3���!�!�"�+�.�.�.�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/�
/����
/�
/�
/�
/��	/�	/rDc�,�dD]�}|�|���5tj|dg��}|�|jd��|�|gd��|�|dgd��ddd��n#1swxYwY��dS)N)z-tz--thresholdr�1000i�r"r#r[)rrrr$�	thresholdrr5s   r�test_thresholdz ParseArgsTestCase.test_threshold,s���&�	C�	C�C����#��&�&�
C�
C� �,�c�6�]�;�;��� � ���t�4�4�4������'>�?�?�?�����e��.A�B�B�B�	
C�
C�
C�
C�
C�
C�
C�
C�
C�
C�
C����
C�
C�
C�
C��	C�	Cs�A!B�B	�B	c��dD]�}|�|���5tjtj����5}tj|g��}ddd��n#1swxYwY|�|j��|�	��}|�
d|��ddd��n#1swxYwY��dS)N)�-nz--nowindowsrz)the --nowindows (-n) option is deprecated)r�
contextlib�redirect_stderr�io�StringIOrrr,�	nowindowsrr)rr�stderrr'rs     r�test_nowindowsz ParseArgsTestCase.test_nowindows4sM��&�	P�	P�C����#��&�&�
P�
P��/���
�
�>�>�8�&�$�0�#��7�7�B�8�8�8�8�8�8�8�8�8�8�8����8�8�8�8������-�-�-��o�o�'�'���
�
�I�3�O�O�O�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P����
P�
P�
P�
P��	P�	Ps6�&B>�A#�B>�#A'�'B>�*A'�+AB>�>C	�C	c���dD]_}|�|���5tj|g��}|�|j��ddd��n#1swxYwY�`dS)N)z-F�	--foreverr)rrrr,�foreverr5s   r�test_foreverzParseArgsTestCase.test_forever=rirDc�4�|�dgd��dS)Nz--xxxzusage:�r�rs r�test_unrecognized_argumentz,ParseArgsTestCase.test_unrecognized_argumentCs������	�8�,�,�,�,�,r)c��tjdg��}|�|j��|�|jd��dS)Nz--quir)rrr,rLr$r=r&s  r�test_long_option__partialz+ParseArgsTestCase.test_long_option__partialFsF��
�
$�g�Y�
/�
/�������!�!�!������Q�'�'�'�'�'r)c���tjddg��}|�|j��|�|jd��|�|j��dS)NrKrfr)rrr,rLr$r=rgr&s  r�test_two_optionsz"ParseArgsTestCase.test_two_optionsKs]��
�
$�i��%=�
>�
>�������!�!�!������Q�'�'�'�����
�#�#�#�#�#r)c�h�tjddg��}|�|jd��dS)Nr3�)rrr$r4r&s  r�#test_option_with_empty_string_valuez5ParseArgsTestCase.test_option_with_empty_string_valueQs4��
�
$�i��_�
5�
5�������2�&�&�&�&�&r)c�h�tjdg��}|�|jdg��dS)Nr#)rrr$rr&s  r�test_argzParseArgsTestCase.test_argUs4��
�
$�e�W�
-�
-�������5�'�*�*�*�*�*r)c���tjddg��}|�|j��|�|jd��|�|jdg��dS)NrKr#r)rrr,rLr$r=rr&s  r�test_option_and_argz%ParseArgsTestCase.test_option_and_argYsc��
�
$�i��%7�
8�
8�������!�!�!������Q�'�'�'������5�'�*�*�*�*�*r)c��tjgd���}|�|jd��|�|jddg��dS)N)�test_unaryopr9�
test_binopr:r�r�)rrr$r=rr&s  r�test_arg_option_argz%ParseArgsTestCase.test_arg_option_arg_sT��
�
$�%I�%I�%I�
J�
J�������Q�'�'�'������>�<�"@�A�A�A�A�Ar)c�4�|�dgd��dS)Nz--unknown-optionz(unrecognized arguments: --unknown-optionr�r�s r�test_unknown_optionz%ParseArgsTestCase.test_unknown_optionds0�����+�,�B�	D�	D�	D�	D�	Dr)N),�__name__�
__module__�__qualname__�__doc__rrr(r.r1r6r>rBrHrMrQrTrXr]rdrhrlr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��r)rr
r
+s���������+�+�+�
N�N�N�E�E�E�!�!�!�D�D�D�
@�@�@�
(�
(�
(�-�-�-�-�-�-�0�0�0�/�/�/�#�#�#�.�.�.�D�D�D�I�I�I�,�,�,�I�I�I�7�7�7�$@�@�@�,N�N�N�G�G�G�2@�@�@�@�@�@�
-�-�-�L�L�L�"G�G�G�*�*�*�@�@�@�/�/�/�C�C�C�P�P�P�,�,�,�-�-�-�(�(�(�
$�$�$�'�'�'�+�+�+�+�+�+�B�B�B�
D�D�D�D�Dr)r
c	�h�eZdZdZdZdZd�Zdd�Zd�Zd�Z	d	�Z
d
d
d
d
id
dddf	d�Zd
�Zdd�Z
d�ZdS)�BaseTestCaser:�test_regrtest_ztest_[a-zA-Z0-9_]+c��tj�tj�t����|_t
j��|_|�	tj|j��dSr)r}r~�realpath�dirname�__file__r��tempfile�mkdtemp�
tmptestdirrxr�rmtreer�s r�setUpzBaseTestCase.setUpnsV���w�'�'������(A�(A�B�B���"�*�,�,������	�(�$�/�:�:�:�:�:r)Nc�&�|s$dtjz}txjdz
c_|�tjd��}|j|z}t
j�|j|dz��}|�	tj|��	t|dd���5}|�
|��ddd��n#1swxYwYnA#t$r4}tj��s|�d|�d	|�����d}~wwxYw|S)
Nznoop%sr:z�
                    import unittest

                    class Tests(unittest.TestCase):
                        def test_empty_test(self):
                            pass
                z.py�xzutf-8)�encodingz
cannot write z: )r��TEST_UNIQUE_ID�textwrap�dedent�TESTNAME_PREFIXr}r~r�r�rxrryr{�write�PermissionError�	sysconfig�is_python_build�skipTest)r�name�coder~r��excs      r�create_testzBaseTestCase.create_testts]���	-��l�9�9�D��'�'�1�,�'�'��<��?�$���D��#�d�*���w�|�|�D�O�T�E�\�:�:�����	�(�$�/�/�/�	��d�C�'�2�2�2�
�b��������
�
�
�
�
�
�
�
�
�
�
����
�
�
�
����	�	�	��,�.�.�
C��
�
�
�t�t�t�S�S�A�B�B�B������	�����s<�C�"C�8C�C�C�C�C�
D�/D	�	Dc�~�tj||tj��}|s|�|�d|����|S)Nz not found in )�re�search�	MULTILINE�fail)r�regex�outputrus    r�regex_searchzBaseTestCase.regex_search�sA���	�%����6�6���	>��I�I�e�e�e�V�V�<�=�=�=��r)c�v�tjd|ztj��}|�||��dS)N�^)r�compiler
�assertRegex�rr
rs   r�
check_linezBaseTestCase.check_line�s5���
�4�%�<���6�6�������'�'�'�'�'r)c��dt�d|j�d�}tj||tj��}td�|D����S)Nrz\[ *[0-9]+(?:/ *[0-9]+)*\] (�)c3�@K�|]}|�d��V��dS)r:N��group��.0rus  r�	<genexpr>z4BaseTestCase.parse_executed_tests.<locals>.<genexpr>�s,����7�7�u�E�K�K��N�N�7�7�7�7�7�7r))�
LOG_PREFIX�TESTNAME_REGEXr�finditerr
r�)rr
r�parsers    r�parse_executed_testsz!BaseTestCase.parse_executed_tests�sO����J�J�� 3� 3� 3�5����U�F�B�L�9�9���7�7��7�7�7�7�7�7r)r�Fc	���t|t��r|g}t|t��r|g}t|t��r|g}t|t��r|g}t|t��r|g}t|t��r|g}|�|��}|	r2|�t	|��t	|��|��n|�|||��d���fd�}
|r"|
d|��}|�||��|r"|
d|��}|�||��|r"|
d|��}|�||��|r"|
d|��}|�||��|r�|
d|�����}|�||��tdz}|�||��|���D],\}}td	|�d
|�d�z}|�||���-|r"|
d|��}|�||��t|��t|��z
t|��z
t|��z
t|��z
t|��z
}|r6|�d
�|���d�}|s
|s|dkrd|z}|�||��|
r|�|d��g}|r|�
d��n|r|r|�
d��|
r|�
d��t||||
|||f��s|�
d��n|s|�
d��d�|��}|r|�|d��d|z}|�|d|z��dS)Nc��|dkrdndS)Nr:�sr�r�)�counts r�pluralz1BaseTestCase.check_executed_tests.<locals>.plural�s���1�*�*�3�3�"�,r)c���t|��}d�t|����}||�|��fz}|�d|�d�}|S)N� z:\n    �$)�lenr��sorted)�line_format�testsr%�namesrr&s     �r�
list_regexz5BaseTestCase.check_executed_tests.<locals>.list_regex�sS�����J�J�E��H�H�V�E�]�]�+�+�E��5�&�&��-�-�"8�8�E�',�u�u�e�e�e�4�E��Lr)z%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 testz OK\.$r:zAll %sz(Test suite interrupted by signal SIGINT.�FAILUREzENV CHANGED�INTERRUPTEDzNO TEST RUN�SUCCESS�, zTests result: FAILUREzFAILURE then %szTests result: %s)
�
isinstance�strr!r$�setr�keysr�itemsr*�append�anyr�)rr
r-�skipped�failed�env_changed�omitted�rerun�no_test_ranrW�interrupted�fail_env_changed�executedr/rrru�good�resultr&s                   @r�check_executed_testsz!BaseTestCase.check_executed_tests�s����
�e�S�!�!�	��G�E��g�s�#�#�	 ��i�G��f�c�"�"�	��X�F��k�3�'�'�	(�&�-�K��g�s�#�#�	 ��i�G��k�3�'�'�	(�&�-�K��,�,�V�4�4���	6����S��]�]�C��J�J��?�?�?�?����X�u�f�5�5�5�	-�	-�	-�	�	�	�	�	��	+��J�2�G�<�<�E��O�O�F�E�*�*�*��	+��J�1�6�:�:�E��O�O�F�E�*�*�*��	+��J�L�*�,�,�E��O�O�F�E�*�*�*��	+��J�2�G�<�<�E��O�O�F�E�*�*�*��	/��J�1�5�:�:�<�<�@�@�E��O�O�F�E�*�*�*��!K�K�E��O�O�F�E�*�*�*�$�{�{�}�}�
/�
/���e�"�%a�4�%a�%a�W\�%a�%a�%a�a�������.�.�.�.��	+��J�7��E�E�E��O�O�F�E�*�*�*��E�
�
�S��\�\�)�C��K�K�7��g�,�,��!$�[�!1�!1�2�47��4D�4D�E���	+�*.�$�$���t�����=�E��
)�6�
)�d�Q�h�h� �5�(���O�O�F�E�*�*�*��	P��O�O�F�$N�O�O�O����	)��M�M�)�$�$�$�$�
�	)�+�	)��M�M�-�(�(�(��	)��M�M�-�(�(�(��D�&�&�+�w��!1�3�4�4�	%��M�M�-�(�(�(�(��	%��M�M�)�$�$�$����6�"�"���	0��O�O�F�$;�<�<�<�&��/�F����� 2�V� ;�<�<�<�<�<r)c��|�d|��}t|�d����}|�d|cxkodknc|��|S)NzUsing random seed ([0-9]+)r:ri���)r�intrr,)rr
ru�randseeds    r�parse_random_seedzBaseTestCase.parse_random_seedsd���!�!�"?��H�H���u�{�{�1�~�~�&�&������X�1�1�1�1��1�1�1�1�8�<�<�<��r)rc�"�|sd}d|vrtj|d<tj|fd|tjd�|��}|j|krLdt|���d|j�d|j�d�}|jr
|d	|jzz
}|�|��|S)
Nr�r�T)�universal_newlines�input�stdoutzCommand z failed with exit code z

stdout:
---
z
---
z
stderr:
---
%s---
)	�
subprocess�STDOUT�run�PIPE�
returncoder5rNr�r)rrrM�exitcode�kw�procrs       r�run_commandzBaseTestCase.run_commands����	��E��2���%�,�B�x�L��~�d�$�15�$)�%/�_�$�$�!#�	$�$��
�?�h�&�&�&��$�i�i�i�i�����$�+�+�+�
?�C��{�
'�� �
�+�&�'��
�I�I�c�N�N�N��r)c�P�tjdddg|�}|j|fi|��}|jS)Nz-X�faulthandlerz-I)�sys�
executablerWrN)rrrUrVs    r�
run_pythonzBaseTestCase.run_python"s9�����n�d�B�T�B���t���+�+��+�+���{�r))NN)Nr)r�r�r�r�r�rr�rrrr!rFrJrWr\r�r)rr�r�is��������N�&�O�*�N�;�;�;�����<���(�(�(�8�8�8�;=�R�)+�R�#%�2�',�%�.3�	\=�\=�\=�\=�|�������8����r)r�c��eZdZd�ZdS)�CheckActualTestsc	���gd�}|�|��}t|�����}tj�t
jtj�t����d��}tt
j|����}|�
||dzdzdd�|����������dS)	zP
        Check that regrtest appears to find the expected set of tests.
        )�-Wd�-E�-bbrt�
test.regrtest�--list-testsztest*.py�	�
z+Unexpectedly low number of tests found in:
r3)rN)r\r*�
splitlinesr}r~r��glob�escaper�r��
assertGreater)rrr
�rough_number_of_tests_found�actual_testsuite_glob�rough_counted_test_py_filess      r�#test_finds_expected_number_of_testsz4CheckActualTests.test_finds_expected_number_of_tests)s���K�J�J������&�&��&)�&�*;�*;�*=�*=�&>�&>�#� "����T�[������9R�9R�-S�-S�-7�!9�!9��&)�$�)�4I�*J�*J�&K�&K�#�	
���6�6�q�8�"�<� ?�"�i�i��(9�(9�(;�(;�<�<� ?� ?�	�	@�	@�	@�	@�	@r)N)r�r�r�rnr�r)rr^r^(s(������@�@�@�@�@r)r^c�~��eZdZdZdZ�fd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ejej��d��d
���Zd�Zejej��d��ejejdkd��d�����Zejejdkd��d���Z�xZS)�ProgramsTestCasezp
    Test various ways to run the Python test suite. Use options close
    to options used on the buildbot.
    r�c�V���t������fd�t�j��D���_gd��_ddd�jzg�_�j�d��tj
dkr�j�d��dSdS)	Nc�8��g|]}������Sr��r�r�indexrs  �r�
<listcomp>z*ProgramsTestCase.setUp.<locals>.<listcomp>Ls%���H�H�H�U�d�&�&�(�(�H�H�Hr))r`rarbz-uallz-rwW�--testdir=%s)r!�3600z-j4�win32r�)�superr��range�NTESTr-�python_argsr��
regrtest_args�extendrZ�platformr9)r�	__class__s`�rr�zProgramsTestCase.setUpHs�����
���
�
����I�H�H�H�e�D�J�6G�6G�H�H�H��
�/�/�/���%�v�,�t��>�@�����!�!�">�?�?�?��<�7�"�"���%�%�d�+�+�+�+�+�#�"r)c�j�|�|��|�||jd���dS)NT)rW)rJrFr-)rr
s  r�check_outputzProgramsTestCase.check_outputUs9�����v�&�&�&��!�!�&�$�*��!�E�E�E�E�Er)c�Z�|�|��}|�|��dSr)r\r�)rrr
s   r�	run_testszProgramsTestCase.run_testsYs-������&�&�����&�!�!�!�!�!r)c��tj�|jd��}g|j�|�|j�|j�}|�|��dS)Nzregrtest.py�r}r~r�r�r}r~r-r��r�scriptrs   r�test_script_regrtestz%ProgramsTestCase.test_script_regrtest]sR������d�l�M�:�:��L��!�L�6�L�D�,>�L���L�����t�����r)c�f�g|j�d�d�|j�|j�}|�|��dS)Nrt�test�r}r~r-r��rrs  r�test_module_testz!ProgramsTestCase.test_module_testdsN��2��!�2�4�2��2��#�2�&*�j�2�����t�����r)c�f�g|j�d�d�|j�|j�}|�|��dS)Nrtrcr�r�s  r�test_module_regrtestz%ProgramsTestCase.test_module_regrtestj�N��2��!�2�4�2��2��#�2�&*�j�2�����t�����r)c�f�g|j�d�d�|j�|j�}|�|��dS)Nrtz
test.autotestr�r�s  r�test_module_autotestz%ProgramsTestCase.test_module_autotestpr�r)c�j�d}g|j�d�|�|j�|j�}|�|��dS)Nzfrom test import autotestz-cr�)rrrs   r�test_module_from_test_autotestz/ProgramsTestCase.test_module_from_test_autotestvsS��*��2��!�2�4�2��2��#�2�&*�j�2�����t�����r)c��tj�|jd��}g|j�|�|j�|j�}|�|��dS)Nzautotest.pyr�r�s   r�test_script_autotestz%ProgramsTestCase.test_script_autotest}sR������d�l�M�:�:��L��!�L�6�L�D�,>�L���L�����t�����r)z$run_tests.py script is not installedc��tj�tddd��}|g|j�|j�}|�|��dS)N�Tools�scriptszrun_tests.py)r}r~r��ROOT_DIRr~r-r�r�s   r�test_tools_script_run_testsz,ProgramsTestCase.test_tools_script_run_tests�sL������h���N�K�K���9��+�9�d�j�9�����t�����r)c�d�|�|��}|�|j��dSr)rWr�rN)rrrVs   r�	run_batchzProgramsTestCase.run_batch�s1������%�%�����$�+�&�&�&�&�&r)z test.bat script is not installedryzWindows onlyc���tj�tddd��}d|jzg}tj��dkr|�d��n_tj��dkr|�d��n2tj��d	d
kr|�d��ts|�d��|j
|g|�|j�R�dS)
Nr��buildbotztest.batrw�ARM64�-arm64�ARM�-arm32r�64bit�-x64z+d)r}r~r�r�r�r��machiner9�architecture�Py_DEBUGr�r-)rr��	test_argss   r�test_tools_buildbot_testz)ProgramsTestCase.test_tools_buildbot_test�s���
����h���Z�H�H��#�d�o�5�6�	������(�(����X�&�&�&�&�
�
�
�
�5�
(�
(����X�&�&�&�&�
�
"�
$�
$�Q�
'�7�
2�
2����V�$�$�$��	#����T�"�"�"����v�7�	�7�D�J�7�7�7�7�7�7r)c�N�tj�td��}tj�|��s|�d|�d���dg}t
j��dkr|�d��n_t
j��dkr|�d��n2t
j	��d	d
kr|�d��tr|�d��|j|g|�|j�|j
�R�dS)
NzPCbuild\rt.batzFile "z" does not existrJr�r�r�r�rr�r�z-d)r}r~r�r��isfilerr�r�r9r�r�r�r~r-)rr��rt_argss   r�test_pcbuild_rtz ProgramsTestCase.test_pcbuild_rt�s������h�(9�:�:���w�~�~�f�%�%�	=��M�M�;�6�;�;�;�<�<�<��&�������(�(��N�N�8�$�$�$�$�
�
�
�
�5�
(�
(��N�N�8�$�$�$�$�
�
"�
$�
$�Q�
'�7�
2�
2��N�N�6�"�"�"��	!��N�N�4� � � ����v�J��J�$�*<�J�t�z�J�J�J�J�J�Jr))r�r�r�r�r|r�r�r�r�r�r�r�r�r��unittest�
skipUnlessrrr�r�rZr�r�r��
__classcell__)r�s@rrprp@s����������

�E�,�,�,�,�,�F�F�F�"�"�"��������������������X��2��2�4�4�?�A�A���A�A��'�'�'��X��2��2�4�4�;�=�=��X�����0�.�A�A�8�8�B�A�=�=�8��X�����0�.�A�A�K�K�B�A�K�K�K�K�Kr)rpc�n�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zejed��d���Zejed��d���Zd�Zd�Zejd���Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#ejd���Z$d�Z%d �Z&d!�Z'd"�Z(d#�Z)d$�Z*d%S)&�ArgsTestCasez2
    Test arguments of the Python test suite.
    c�<�ddd|jzg|�}|j|fi|��S)Nrtr�rw)r�r\)r�testargsrU�cmdargss    rr�zArgsTestCase.run_tests�s4�����$�/�!A�M�H�M���t��w�-�-�"�-�-�-r)c���tjd��}|�d��}|�d|���}||g}|j|ddi�}|�|||���dS)Nz�
            import unittest

            class FailingTest(unittest.TestCase):
                def test_failing(self):
                    self.fail("bug")
        �ok�failing�rrTr��r<�r�r�rr�rF)rr�test_ok�test_failingr-r
s      r�test_failing_testzArgsTestCase.test_failing_test�s����� �
�
���"�"�4�(�(���'�'�	��'�=�=���,�'������3��3�3���!�!�&�%��!�E�E�E�E�Er)c��i}dD]2}tjd|z��}|�||��||<�3t|�����}|jddg|�R�}|�||��|jdg|�R�}|�|||d���|j|�}|�|||���dS)N)�audior�a
                        from test import support; support.requires(%r)
                        import unittest
                        class PassingTest(unittest.TestCase):
                            def test_pass(self):
                                pass
                    r��allz-uaudior�)r;)r�r�rr+�valuesr�rF)rr-�resourcer�
test_namesr
s      r�test_resourceszArgsTestCase.test_resources�s����,�		?�		?�H��?�$�#�
$#�$�$�D�#�.�.�x��>�>�E�(�O�O��E�L�L�N�N�+�+�
� ����e�9�j�9�9�9���!�!�&�*�5�5�5� ���	�7�J�7�7�7���!�!�&�*�*/�	�*:�	"�	<�	<�	<� ����,���!�!�&�*�*4�	"�	6�	6�	6�	6�	6r)c�F�tjd��}|�d|��}|�d|��}|�|��}|�d|��}t
|�d����}|�dd|z|��}|�|��}|�||��|�d|��}t
|�d����}|�||��dS)Nza
            import random
            print("TESTRANDOM: %s" % random.randint(1, 1000))
        �randomrVzTESTRANDOM: ([0-9]+)r:z
--randseed=%s)	r�r�rr�rJrrHrr$)	rrr�r
rIru�test_random�	randseed2�test_random2s	         rr�zArgsTestCase.test_random�s���� �
�
������$�/�/������d�+�+���)�)�&�1�1���!�!�"9�6�B�B���%�+�+�a�.�.�)�)������o��&@�$�G�G���*�*�6�2�2�	�����H�-�-�-��!�!�"9�6�B�B���5�;�;�q�>�>�*�*������{�3�3�3�3�3r)c
����fd�td��D��}tj}��tj|��t|d��5}d}t
|d��D]8\}}d||t|��|fz}|r|d|zz
}t||���|}�9	ddd��n#1swxYwY��	d|��}��
||��t|d��5}t
|d��D],\}}td	|�d
t|���d|��|����-	ddd��n#1swxYwY��	d|��}��
||��t|d��5}|D]}t||����	ddd��n#1swxYwY��	d|��}��
||��t|d��5}|D]}td|z|����	ddd��n#1swxYwY��	d|��}��
||��dS)
Nc�8��g|]}������Sr�rsrts  �rrvz.ArgsTestCase.test_fromfile.<locals>.<listcomp>�%���:�:�:���!�!�#�#�:�:�:r)r�ror:z00:00:%02i [%s/%s] %sz -- %s took 0 secrqr`�[�/z] zLib/test/%s.py)r{rrzrxryr{�	enumerater*r|r�rF)	rr-r�r��previousrur�liner
s	`        rrdzArgsTestCase.test_fromfile�s����:�:�:�:��q���:�:�:��
�#�����	�(�(�3�3�3��(�C�
 �
 �	 �B��H�(���2�2�
 �
 ���t�/� �%��U���T�:�;���;��/�(�:�:�D��d��$�$�$�$����

 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �����h�7�7���!�!�&�%�0�0�0��(�C�
 �
 �	I�B�(���2�2�
I�
I���t���e�e�e�S��Z�Z�Z�Z���>�R�H�H�H�H�H�
I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I�����h�7�7���!�!�&�%�0�0�0��(�C�
 �
 �	%�B��
%�
%���d��$�$�$�$�$�
%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�����h�7�7���!�!�&�%�0�0�0��(�C�
 �
 �	8�B��
8�
8���&��-�B�7�7�7�7�7�
8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�����h�7�7���!�!�&�%�0�0�0�0�0sI�AB2�2B6�9B6�9>E�E�E�F/�/F3�6F3�6H�H!�$H!c��t}|�d|���}|�|d���}|�|||d���dS)N�sigintr���rTT�r>rA)�TEST_INTERRUPTEDrr�rF�rrr�r
s    r�test_interruptedzArgsTestCase.test_interrupted/sd��������t��4�4������s��3�3���!�!�&�$��.2�	"�	4�	4�	4�	4�	4r)c�����fd�td��D��}�jdg|�R�}��||��d�j�dt	|���d�}��||��dS)Nc�8��g|]}������Sr�rsrts  �rrvz-ArgsTestCase.test_slowest.<locals>.<listcomp>8r�r)r;rOz10 slowest tests:
(?:- z: .*
){�})r{r�rFrr*r)rr-r
rs`   rrQzArgsTestCase.test_slowest6s����:�:�:�:��q���:�:�:������4�e�4�4�4���!�!�&�%�0�0�0�0��'�'�'��U�����5��	
�����&�&�&�&�&r)c�<�t}|�d|���}dD]z}|�|���5|rdd|f}nd|f}|j|ddi�}|�|||d	�
��d}|�||��ddd��n#1swxYwY�{dS)Nr�r�)FT)�multiprocessingrO�-j2rTr�Tr�z10 slowest tests:
)r�rrr�rFr)rrr�r�rr
rs       r�test_slowest_interruptedz%ArgsTestCase.test_slowest_interrupted@s��������t��4�4��,�	/�	/�O����o��>�>�

/�

/�"�/�'���5�D�D�'��.�D�'����<��<�<���)�)�&�$�26�D�*�J�J�J�/�������.�.�.�

/�

/�

/�

/�

/�

/�

/�

/�

/�

/�

/����

/�

/�

/�

/��	/�	/s�AB�B	�B	c��|�d��}|�d|��}|�||g��d}|�||��dS)N�coverager�zLlines +cov% +module +\(path\)\n(?: *[0-9]+ *[0-9]{1,2}% *[^ ]+ +\([^)]+\)+)+)rr�rFr)rr�r
rs    rr�zArgsTestCase.test_coverageRsb�����
�+�+������d�3�3���!�!�&�4�&�1�1�1�B�������&�&�&�&�&r)c��|�d��}|�d|d���}|�|d��dS)Nr-r+�key)rMzPress any key to continue)rr�r)rr�r
s   rr.zArgsTestCase.test_wait[sG������'�'������$�e��<�<������ ;�<�<�<�<�<r)c���tjd��}|�d|���}|�d|d���}|�||gdz|���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�r�r�r�r�r;r�r�r�s    rr�zArgsTestCase.test_foreverasp���� �
�
�����	���5�5������T�A��>�>���!�!�&�4�&��(�4�!�@�@�@�@�@r)c�&�|�d|���}d}|�tj|��|�dd|dt
j���}|�||g|���d	}|�|tj
|����|�d
|�d�}|�||��t|��5}|�
��}	|�||	��ddd��dS#1swxYwYdS)Nr�r�r�r�z3:3:r�)rTr�r�z&beginning 6 repetitions
123456
......
z leaked [1, 1, 1] z, sum=3
)rrxrryr�rOrPrFrrrirr{�read)
rr�whatr�r�r
r��line2r��reflogs
          r�
check_leakzArgsTestCase.check_leakvsQ������4��8�8�������	�(�(�3�3�3�������)*�'1�'8� �:�:��	
�!�!�&�4�&��!�>�>�>�:�������	�$���0�0�0�59�T�T�4�4�4�@���
�
�e�V�$�$�$�
�(�^�^�	)�r��W�W�Y�Y�F��M�M�%��(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�+D�D
�
D
zneed a debug buildc�Z�tjd��}|�|d��dS)Nz�
            import unittest

            GLOBAL_LIST = []

            class RefLeakTest(unittest.TestCase):
                def test_leak(self):
                    GLOBAL_LIST.append(object())
        �
references�r�r�r��rrs  rr�zArgsTestCase.test_huntrleaks�s6���� �
�
��	
����l�+�+�+�+�+r)c�Z�tjd��}|�|d��dS)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 descriptorsr�r�s  r�test_huntrleaks_fd_leakz$ArgsTestCase.test_huntrleaks_fd_leak�s7���� �
�
��	
����0�1�1�1�1�1r)c�����fd�td��D��}�jdg|�R�}��|������|��dS)Nc�8��g|]}������Sr�rs)r�irs  �rrvz0ArgsTestCase.test_list_tests.<locals>.<listcomp>�s%���6�6�6���!�!�#�#�6�6�6r)r�rd)r{r�r$�rstriprg)rr-r
s`  r�test_list_testszArgsTestCase.test_list_tests�sv���6�6�6�6�U�1�X�X�6�6�6������7��7�7�7����������3�3�5�5��	 �	 �	 �	 �	 r)c�v�tjd��}|�|���}d|zd|zg}|�d|��}|�|���|��d|zg}|�ddd|��}|�|���|��dS)Nz�
            import unittest

            class Tests(unittest.TestCase):
                def test_method1(self):
                    pass
                def test_method2(self):
                    pass
        r�z%s.Tests.test_method1z%s.Tests.test_method2z--list-casesrt�test_method1)r�r�rr�r$rg)rr�testname�all_methodsr
s     r�test_list_caseszArgsTestCase.test_list_cases�s����� �
�
���#�#��#�.�.��/��9�.��9�;�������9�9������*�*�,�,�k�:�:�:�/��9�:������ $�n� (�*�*��	
����*�*�,�,�k�:�:�:�:�:r)c��d}|�d|���}|g}|jdg|�Rddi�}|�|||d���dS)	Nz,import faulthandler; faulthandler._sigsegv()�crash)rrr�rTr�T)r<rW)rr�rF)rr�
crash_testr-r
s     r�test_crashedzArgsTestCase.test_crashed�sy��>���%�%�7��%�>�>�
��������:��:�:�:��:�:���!�!�&�%�
�,0�	"�	2�	2�	2�	2�	2r)c��tjdtj���}d�|�|��D��S)Nz^(test[^ ]+).*ok$)�flagsc�8�g|]}|�d����S)r:rrs  rrvz.ArgsTestCase.parse_methods.<locals>.<listcomp>�s"��C�C�C�5����A���C�C�Cr))rrr
rrs   r�
parse_methodszArgsTestCase.parse_methods�s9���
�.�b�l�C�C�C��C�C�E�N�N�6�,B�,B�C�C�C�Cr)c���tjd��}gd�}|�|���}tj}|�tj|��dd|zg}t|d��5}|D]}t||����	ddd��n#1swxYwY|�	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
        �r��test_method2�test_method3�test_method4r�r��%s.Tests.test_method3rorqr9rvrr
)r�r�rrrzrxryr{r|r�rr$)
rrr�r�r��subsetr�rr
�methodss
          r�test_ignorefilezArgsTestCase.test_ignorefile�sT���� �
�
��7�7�7���#�#��#�.�.���#�����	�(�(�3�3�3�
�#�h�.�	0��
�(�C�
 �
 �	%�B��
%�
%���d��$�$�$�$�$�
%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�����n�h��I�I���$�$�V�,�,�� �.�1������&�)�)�)�)�)s�2B�B�Bc�V�tjd��}gd�}|�|���}|�d|��}|�|��}|�||��tj}|�tj	|��dd|zg}t|d��5}|D]}	t|	|����	ddd��n#1swxYwY|�dd	||��}|�|��}dd
g}|�||��dS)Nr	r
r�r9r�rrorqr�r)r�r�rr�rr$rrzrxryr{r|)
rrr�r�r
rr�rr�rs
          r�test_matchfilezArgsTestCase.test_matchfile�s����� �
�
��7�7�7���#�#��#�.�.������h�/�/���$�$�V�,�,������+�.�.�.��#�����	�(�(�3�3�3�
�#�h�.�	0��
�(�C�
 �
 �	%�B��
%�
%���d��$�$�$�$�$�
%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�����m�X�x�H�H���$�$�V�,�,�� �.�1������&�)�)�)�)�)s�3C�C�Cc��tjd��}|�|���}|�|��}|�||g|���|�d|d���}|�||g|d���dS)	Nz�
            import unittest

            class Tests(unittest.TestCase):
                def test_env_changed(self):
                    open("env_changed", "w").close()
        r�)r=�--fail-env-changedr;r�T�r=rBr��rrr�r
s    r�test_env_changedzArgsTestCase.test_env_changed#s����� �
�
���#�#��#�.�.������)�)���!�!�&�8�*�(�!�K�K�K���� 4�h���K�K���!�!�&�8�*�(�37�	"�	9�	9�	9�	9�	9r)c���tjd��}|�|���}|�d|d���}|�||g||di���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")
        r�r@r�r��test_fail_always)r<r?r�rs    r�test_rerun_failzArgsTestCase.test_rerun_fail6s�����
 �

�

���#�#��#�.�.������h���;�;���!�!�&�8�*�)1�(�DV�9W�	"�	Y�	Y�	Y�	Y�	Yr)c��tjd��}|�|���}|�d|d���}|�||g|di���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")
        r�r@rr��test_fail_once)r?r�rs    r�test_rerun_successzArgsTestCase.test_rerun_successIs����� �
�
���#�#��#�.�.������h���;�;���!�!�&�8�*�)1�3C�(D�	"�	F�	F�	F�	F�	Fr)c��tjd��}|�|���}|�|ddd���}|�||g|���dS�N��
            import unittest

            class Tests(unittest.TestCase):
                def test_bug(self):
                    pass
        r�rt�
nosuchtestrr��r@r�rs    r�test_no_tests_ranzArgsTestCase.test_no_tests_ran^sl���� �
�
���#�#��#�.�.������$��q��I�I���!�!�&�8�*�(�!�K�K�K�K�Kr)c��tjd��}|�|���}|�|d���}|�||g��dS)Nz�
            import unittest

            class Tests(unittest.TestCase):
                def test_skipped(self):
                    self.skipTest("because")
        r�rr�r�rs    r�test_no_tests_ran_skipz#ArgsTestCase.test_no_tests_ran_skipksc���� �
�
���#�#��#�.�.������1��5�5���!�!�&�8�*�5�5�5�5�5r)c���tjd��}|�|���}|�|���}|�||ddd���}|�|||g||g���dSr r�)rrr��	testname2r
s     r�,test_no_tests_ran_multiple_tests_nonexistentz9ArgsTestCase.test_no_tests_ran_multiple_tests_nonexistentxs����� �
�
���#�#��#�.�.���$�$�$�$�/�/�	�����)�T�<�RS��T�T���!�!�&�8�Y�*?�/7��.C�	"�	E�	E�	E�	E�	Er)c	��tjd��}|�|���}tjd��}|�|���}|�||ddddd���}|�|||g|g�	��dS)
Nr!r�z�
            import unittest

            class Tests(unittest.TestCase):
                def test_other_bug(self):
                    pass
        rtr"�test_other_bugrr�r#r�)rrr��
other_coder(r
s      r�)test_no_test_ran_some_test_exist_some_notz6ArgsTestCase.test_no_test_ran_some_test_exist_some_not�s����� �
�
���#�#��#�.�.���_�&�
�
�
��$�$�*�$�5�5�	�����)�T�<� $�&6�� �D�D���!�!�&�8�Y�*?�/7�j�	"�	:�	:�	:�	:�	:r)c��tjd��}|�|���}|�d|d���}|�||g|gd���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
        r�rr;r�Trr�rs    r�test_uncollectablezArgsTestCase.test_uncollectable�s}���� �
�
��"�#�#��#�.�.����� 4�h���K�K���!�!�&�8�*�/7�j�37�	"�	9�	9�	9�	9�	9r)c�*�tjd��}|�|���}|�dd|d���}|�||g|���|�|t
jd|ztj����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)
        r�r�z
--timeout=1.0r�r�r�z%s timed out)	r�r�rr�rFrrrr
rs    r�test_multiprocessing_timeoutz)ArgsTestCase.test_multiprocessing_timeout�s����� �
�
��$�#�#��#�.�.��������1��M�M���!�!�&�8�*�)1�	"�	3�	3�	3�������N�X�$=�r�|�L�L�	N�	N�	N�	N�	Nr)c��tjd��}|�|���}|�dd|d���}|�||g|gd���|�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(), '')
        r�rr9r;r�TrzWarning -- Unraisable exceptionzException: weakref callback bug�r�r�rr�rFrrs    r�test_unraisable_excz ArgsTestCase.test_unraisable_exc�s����� �
�
��*�#�#��#�.�.����� 4�d�H�q��Q�Q���!�!�&�8�*�/7�j�37�	"�	9�	9�	9�	
�
�
�7��@�@�@��
�
�7��@�@�@�@�@r)c��tjd��}|�|���}|�dd|d���}|�||g|gd���|�d	|��|�d
|��dS)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(), '')
        r�rr9r;r�Trz$Warning -- Uncaught thread exceptionzException: bug in threadr3rs    r�test_threading_excepthookz&ArgsTestCase.test_threading_excepthook�s����� �
�
��&�#�#��#�.�.����� 4�d�H�q��Q�Q���!�!�&�8�*�/7�j�37�	"�	9�	9�	9�	
�
�
�<�f�E�E�E��
�
�0�&�9�9�9�9�9r)c�J�tjd��}|�|���}d}dD]s}|�|���5d||g}|j|ddi�}|�||g|gd	�
��|�||��ddd��n#1swxYwY�tdS)Na%
            import sys
            import unittest
            from test import support

            class MyObject:
                pass

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

            class Tests(unittest.TestCase):
                def test_print_warning(self):
                    print("msg1: stdout")
                    support.print_warning("msg2: print_warning")
                    # Fail with ENV CHANGED to see print_warning() log
                    support.environment_altered = True
        r�zFtest_print_warning.*msg1: stdout\nWarning -- msg2: print_warning\nok\n)r9rF)�optionrrTr;Tr)r�r�rrr�rFr)rrr�rr8�cmdr
s       r�test_print_warningzArgsTestCase.test_print_warnings&���� �
�
��$�#�#��#�.�.����#�	0�	0�F����V��,�,�
0�
0�+�V�X�>��'����9�q�9�9���)�)�&�8�*�7?�j�;?�*�A�A�A�� � ���/�/�/�

0�
0�
0�
0�
0�
0�
0�
0�
0�
0�
0����
0�
0�
0�
0��	0�	0s�AB�B	�B	c���tj�tj��}|�|tj�d���|���r|�d��dSdS)Nz not setzModified guard)r}�environ�getr�UNICODE_GUARD_ENV�assertIsNotNone�isasciir)r�guards  r�test_unicode_guard_envz#ArgsTestCase.test_unicode_guard_env;so���
���u�6�7�7�����U�u�'>�$H�$H�$H�I�I�I��=�=�?�?�	,�
�M�M�*�+�+�+�+�+�	,�	,r)c���tj�|jd��}tj|��tj�|jd��}t|d�����||g}ddd|jzdg}|�|��|D]5}|�tj�	|��|���6dS)N�test_python_123�test_python_456�wbrtr�z--tempdir=%sz	--cleanup)
r}r~r�r��mkdirr{�closer\�assertFalse�exists)rr�r�r.r�rs      r�test_cleanupzArgsTestCase.test_cleanupCs����'�,�,�t��0A�B�B��
�������7�<�<���1B�C�C���X�t���"�"�$�$�$��(�#����!�D�O�3�� ��	
���� � � ��	9�	9�D����R�W�^�^�D�1�1�4�8�8�8�8�	9�	9r)N)+r�r�r�r�r�r�r�r�rdr�rQr�r�r.r�r�r�r�r�r�r�r�r�r�cpython_onlyrrrrrrrr$r&r)r-r/r1r4r6r:rBrKr�r)rr�r��s���������.�.�.�F�F�F� 6�6�6�:4�4�4�..1�.1�.1�`4�4�4�'�'�'�/�/�/�$'�'�'�=�=�=�A�A�A�*)�)�)�(�X���#7�8�8�,�,�9�8�,��X���#7�8�8�2�2�9�8�2� � � �;�;�;�4
��2�2���2�D�D�D�"*�"*�"*�H'*�'*�'*�R9�9�9�&Y�Y�Y�&F�F�F�*L�L�L�6�6�6�
E�
E�
E�:�:�:�.
��9�9���9�2N�N�N�6A�A�A�B:�:�:�>&0�&0�&0�P,�,�,�
9�
9�
9�
9�
9r)r�c��eZdZd�ZdS)�	TestUtilsc�&�|�tjd��d��|�tjd��d��|�tjd��d��|�tjd��d��|�tjd	��d
��|�tjd��d��|�tjd
��d��|�tjd��d��|�tjd��d��|�tjd��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)r$r�format_durationr�s r�test_format_durationzTestUtils.test_format_durationTs�������.�q�1�1��	!�	!�	!�����.�t�4�4��	!�	!�	!�����.�u�5�5� �	"�	"�	"�����.�s�3�3�"�	$�	$�	$�����.�q�1�1�"�	$�	$�	$�����.�v�6�6� �	"�	"�	"�����.�z�:�:�&�	(�	(�	(�����.�x�8�8�!�	#�	#�	#�����.�/E�F�F�'�	)�	)�	)�����.�|�<�<�'�	)�	)�	)�	)�	)r)N)r�r�r�rSr�r)rrNrNSs#������)�)�)�)�)r)rN�__main__).r�r�rhr��os.pathr}r�rrOrZrr�r��timer�r�rr�test.supportr�test.libregrtestrr�has_subprocess_support�SkipTest�hasattrr�r~r�r�r�r�r�normpathrr�r��TestCaser
r�r^rpr�rNr��mainr�r)r�<module>r_s�������������	�	�	�	���������	�	�	�	�����
�
�
�
���������������������������������"�"�"�"�"�"�)�)�)�)�)�)�)�)��%�?�
�(�
�=�
>�
>�>��7�3�*�+�+��
�7�<�<������1�1�4��>�>��
�7�?�?�2�7�+�+�H�5�5�6�6��
E�
�"�8�?�$�	�	��{D�{D�{D�{D�{D��)�{D�{D�{D�|	|�|�|�|�|�8�$�|�|�|�~@�@�@�@�@�|�@�@�@�0oK�oK�oK�oK�oK�|�oK�oK�oK�d^
9�^
9�^
9�^
9�^
9�<�^
9�^
9�^
9�B)�)�)�)�)��!�)�)�)�0�z����H�M�O�O�O�O�O��r)