Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_threadedtempfile.cpython-34.pyo

�
g f��@s�dZdZdZddlZddlmZmZed�ZddlZddl	Z	ddl
mZej�Z
Gdd	�d	ej�ZGd
d�dej�Zedkr�ej�ndS)
an
Create and delete FILES_PER_THREAD temp files (via tempfile.TemporaryFile)
in each of NUM_THREADS threads, recording the number of successes and
failures.  A failure is a bug in tempfile, and may be due to:

+ Trying to create more than one tempfile with the same name.
+ Trying to delete a tempfile that doesn't still exist.
+ Something we've never seen before.

By default, NUM_THREADS == 20 and FILES_PER_THREAD == 50.  This is enough to
create about 150 failures per run under Win98SE in 2.0, and runs pretty
quickly. Guido reports needing to boost FILES_PER_THREAD to 500 before
provoking a 2.0 failure under Linux.
��2�N)�
start_threads�
import_module�	threading)�	print_excc@s(eZdZdZdZdd�ZdS)�TempFileGreedyrc
Cs�tj�|_tj�xjtt�D]\}ytjd�}|j	�Wn'|j
d7_
td|j�Yq&X|jd7_q&WdS)Nzw+b��file)
�io�StringIO�errors�
startEvent�wait�range�FILES_PER_THREAD�tempfileZ
TemporaryFile�close�error_countr�ok_count)�self�i�f�r�?/opt/alt/python34/lib64/python3.4/test/test_threadedtempfile.py�run!s
zTempFileGreedy.runN)�__name__�
__module__�__qualname__rrrrrrrrsrc@seZdZdd�ZdS)�ThreadedTempFileTestcCs�dd�tt�D�}t|tj��WdQXtdd�|D��}dd�|D�}dt|�|dj|�f}|j|g|�|j|tt	�dS)NcSsg|]}t��qSr)r)�.0rrrr�
<listcomp>1s	z2ThreadedTempFileTest.test_main.<locals>.<listcomp>css|]}|jVqdS)N)r)r �trrr�	<genexpr>4sz1ThreadedTempFileTest.test_main.<locals>.<genexpr>cSs;g|]1}|jrt|j�t|jj���qSr)r�str�namer
�getvalue)r r"rrrr!5s	zErrors: errors %d ok %d
%s�
)
r�NUM_THREADSrr�set�sum�len�joinZassertEqualr)rZthreads�okr
�msgrrr�	test_main0s	
zThreadedTempFileTest.test_mainN)rrrr/rrrrr/sr�__main__)�__doc__r(rrZtest.supportrrrZunittestr�	tracebackrZEventrZThreadrZTestCaserr�mainrrrr�<module>s