;
حق"Ic               @   sط   d  Z  d Z d Z d d l Z d d l Z d d l Z d d l m Z m	 Z	 m
 Z
 d d l Z d d l Z d d l m Z e j   Z Gd   d e j  Z Gd	   d
 e j  Z d   Z e d k o e   n d S(   un  
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.
i   i2   i    N(   u   threading_setupu   threading_cleanupu   run_unittest(   u	   print_excc             B   s#   |  Ee  Z d  Z d  Z d   Z d S(   i    c          
   C   s   t  j   |  _ t j   xj t t  D]\ } y t j d  } | j	   Wn' |  j
 d 7_
 t d |  j  Yq& X|  j d 7_ q& Wd  S(   Nu   w+bi   u   file(   u   iou   StringIOu   errorsu
   startEventu   waitu   rangeu   FILES_PER_THREADu   tempfileu   TemporaryFileu   closeu   error_countu	   print_excu   ok_count(   u   selfu   iu   f(    (    u7   /mit/python/lib/python3.0/test/test_threadedtempfile.pyu   run"   s    
 N(   u   __name__u
   __module__u   error_countu   ok_countu   run(   u
   __locals__(    (    u7   /mit/python/lib/python3.0/test/test_threadedtempfile.pyu   TempFileGreedy   s   
u   TempFileGreedyc             B   s   |  Ee  Z d    Z d S(   c          	   C   s  g  } t    } x4 t t  D]& } t   } | j |  | j   q Wt j   d } g  } x\ | D]T } | j   | | j	 7} | j
 o- | j t | j  t | j j     qc qc Wt |   d t |  | d j |  f } |  j | g  |  |  j | t t  d  S(   Ni    u   Errors: errors %d ok %d
%su   
(   u   threading_setupu   rangeu   NUM_THREADSu   TempFileGreedyu   appendu   startu
   startEventu   setu   joinu   ok_countu   error_countu   stru   nameu   errorsu   getvalueu   threading_cleanupu   lenu   assertEqualsu   FILES_PER_THREAD(   u   selfu   threadsu   thread_infou   iu   tu   oku   errorsu   msg(    (    u7   /mit/python/lib/python3.0/test/test_threadedtempfile.pyu	   test_main1   s*    	 	
 

1
N(   u   __name__u
   __module__u	   test_main(   u
   __locals__(    (    u7   /mit/python/lib/python3.0/test/test_threadedtempfile.pyu   ThreadedTempFileTest0   s   
u   ThreadedTempFileTestc               C   s   t  t  d  S(   N(   u   run_unittestu   ThreadedTempFileTest(    (    (    u7   /mit/python/lib/python3.0/test/test_threadedtempfile.pyu	   test_mainK   s    u   __main__(   u   __doc__u   NUM_THREADSu   FILES_PER_THREADu   _threadu   threadu	   threadingu   tempfileu   test.supportu   threading_setupu   threading_cleanupu   run_unittestu   unittestu   iou	   tracebacku	   print_excu   Eventu
   startEventu   Threadu   TempFileGreedyu   TestCaseu   ThreadedTempFileTestu	   test_mainu   __name__(    (    (    u7   /mit/python/lib/python3.0/test/test_threadedtempfile.pyu   <module>   s   	