Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/bisect.cpython-35.opt-2.pyc



���]K�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	dd�Z
dd�Zdd�Zdd	�Z
dd
d�Zdd
�Zdd�Zedkr�e�dS)�NcCsHt|d��2}x|D]}t|d|�qW|j�WdQRXdS)N�w�file)�open�print�flush)�filename�tests�fp�name�r�+/opt/alt/python35/lib64/python3.5/bisect.py�write_testss
r
cCs5|s
dStdt|�|f�t||�|S)NzWrite %s tests into %s)r�lenr
)rrrrr�write_output&s

rcCs
dj|�S)N� )�join)�argsrrr�format_shell_args.srcCs�tjdddg}|j|j�tj|dtjdd�}|j}|rt|�}t	d||f�tj
|�|jj�}|S)Nz-m�testz--list-cases�stdout�universal_newlinesTz1Failed to list tests: %s failed with exit code %s)
�sys�
executable�extend�	test_args�
subprocess�run�PIPE�
returncoderr�exitr�
splitlines)r�cmd�proc�exitcoderrrr�
list_cases2s			
r$cCs�tj�}zct||�tjddd|g}|j|j�tdt|��t	j
|�}|jSWdtj
j|�r�tj|�XdS)Nz-mrz--matchfilez+ %s)�tempfile�mktempr
rrrrrrrrr�os�path�exists�unlink)rrZ
huntrleaks�tmpr!r"rrr�	run_testsBs
r,c	Cs�tj�}|jdddd�|jdddd�|jdd	d
tdddd
�|jddd
tdddd�|j�\}}||_|S)Nz-iz--input�helpzUTest names produced by --list-tests written into a file. If not set, run --list-testsz-oz--outputzResult of the bisectionz-nz--max-tests�type�default�z:Maximum number of tests to stop the bisection (default: 1)z-Nz
--max-iter�dz5Maximum number of bisection iterations (default: 100))�argparse�ArgumentParser�add_argument�int�parse_known_argsr)�parserrrrrr�
parse_argsQs	r8cCs�t�}|jrAt|j��}dd�|D�}WdQRXnt|�}tdt|��tdt|j��td|j|j	f�t
|j|�}t�tj
�}d}yx�t|�|jkr�||j	kr�t|�}t|dd�}tj||�}td|t|�t|�f�t�t||�}td	|t|�f�td
|�|r�td�|}t
|j|�}n
td�t�|d7}q�WWn*tk
r�t�td
�t�YnXtdt|��x|D]}	td|	�qWt�|r>td|�tjtj
�|�}
t|�|jkr�td|tjd|
�f�tjd�n td|tjd|
�f�dS)NcSsg|]}|j��qSr)�strip)�.0�linerrr�
<listcomp>js	zmain.<locals>.<listcomp>zStart bisection with %s testszTest arguments: %szxBisection will stop when getting %s or less tests (-n/--max-tests option), or after %s iterations (-N/--max-iter option)r0�z![+] Iteration %s: run %s tests/%szran %s tests/%srz"Tests failed: use this new subtestz5Tests succeeded: skip this subtest, try a new subbsetzBisection interrupted!zTests (%s):z* %szOutput written into %sz+Bisection completed in %s iterations and %sZsecondsz+Bisection failed after %s iterations and %s)r8�inputrr$rrrrZ	max_testsZmax_iterr�output�time�	monotonic�max�random�sampler,�KeyboardInterrupt�math�ceil�datetimeZ	timedeltarr)rr	rr?Z
start_timeZ	iterationZntestZsubtestsr#rZdtrrr�maines`		'





rI�__main__)r2rHZos.pathr'rFrCrrr%r@r
rrr$r,r8rI�__name__rrrr�<module>s"A