ó
wŪjc           @   sĻ   d  Z  d Z d Z d d l Z d d l m Z m Z m Z e d  Z d d l	 Z	 d d l
 Z
 d d l m Z e j   Z d e j f d	     YZ d
 e	 j f d     YZ d   Z e d k rĖ e   n  d S(   sn  
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(   t   start_threadst   run_unittestt   import_modulet	   threading(   t	   print_exct   TempFileGreedyc           B   s   e  Z d  Z d  Z d   Z RS(   i    c         C   s   t  j    |  _ t j   xi t t  D][ } y t j d  } | j   Wn& |  j	 d 7_	 t
 d |  j  q& X|  j d 7_ q& Wd  S(   Ns   w+bi   t   file(   t   StringIOt   errorst
   startEventt   waitt   ranget   FILES_PER_THREADt   tempfilet   TemporaryFilet   closet   error_countR   t   ok_count(   t   selft   it   f(    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadedtempfile.pyt   run!   s    
(   t   __name__t
   __module__R   R   R   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadedtempfile.pyR      s   t   ThreadedTempFileTestc           B   s   e  Z d    Z RS(   c         C   sß   g  t  t  D] } t   ^ q } t | t j   Wd  QXt d   | D  } g  | D]4 } | j rX t | j	    t | j
 j    ^ qX } d t |  | d j |  f } |  j | g  |  |  j | t t  d  S(   Nc         s   s   |  ] } | j  Vq d  S(   N(   R   (   t   .0t   t(    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadedtempfile.pys	   <genexpr>4   s    s   Errors: errors %d ok %d
%ss   
(   R   t   NUM_THREADSR   R    R	   t   sett   sumR   t   strt   getNameR   t   getvaluet   lent   joint   assertEqualR   (   R   R   t   threadst   okR   R   t   msg(    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadedtempfile.pyt	   test_main0   s    ">(   R   R   R'   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadedtempfile.pyR   /   s   c           C   s   t  t  d  S(   N(   R   R   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadedtempfile.pyR'   =   s    t   __main__(   t   __doc__R   R   R   t   test.test_supportR    R   R   R   t   unittestR   t	   tracebackR   t   EventR	   t   ThreadR   t   TestCaseR   R'   R   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_threadedtempfile.pyt   <module>   s   	