ó
‹wÛjc           @  sO  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m Z d  d l Z d  d l	 Z
 d  d l m Z m Z d  d l m Z d  d l m Z d e j f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z e d k rKe ƒ  n  d S(   iÿÿÿÿ(   t   print_functionN(   t   array(   t   proxy(   t   TESTFNt   run_unittest(   t   support(   t   UserListt   AutoFileTestsc           B  s}   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z RS(   c         C  s   |  j  t d ƒ |  _ d  S(   Nt   wb(   t   openR   t   f(   t   self(    (    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_file.pyt   setUp   s    c         C  s*   |  j  r |  j  j ƒ  n  t j t ƒ d  S(   N(   R
   t   closeR   t   unlinkR   (   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_file.pyt   tearDown   s    	c         C  sk   t  |  j ƒ } | j d ƒ |  j |  j j ƒ  | j ƒ  ƒ |  j j ƒ  d  |  _ |  j t t	 | d ƒ d  S(   Nt
   teststringt   tell(
   R   R
   t   writet   assertEqualR   R   t   Nonet   assertRaisest   ReferenceErrort   getattr(   R   t   p(    (    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_file.pyt   testWeakRefs   s    	c         C  s"   |  j  } | j | j | j d  S(   N(   R
   t   namet   modet   closed(   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_file.pyt   testAttributes'   s    	c         C  sq   |  j  j d ƒ |  j  j ƒ  t d d ƒ } |  j t d ƒ |  _  |  j  j | ƒ } |  j d | j ƒ  |  ƒ d  S(   Nt   12t   bt   xi
   t   rbt
   xxxxxxxxxx(	   R
   R   R   R   R	   R   t   readintoR   t   tostring(   R   t   at   n(    (    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_file.pyt   testReadinto.   s    c         C  sc   t  d d ƒ } |  j j ƒ  |  j t d ƒ |  _ t |  j d ƒ r_ |  j t |  j j | ƒ n  d  S(   NR   R    i
   t   rR#   R"   (	   R   R
   R   R	   R   t   hasattrR   t	   TypeErrorR#   (   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_file.pyt   testReadinto_text7   s
    c         C  sg   t  d d g ƒ } |  j j | ƒ |  j j ƒ  |  j t d ƒ |  _ |  j j ƒ  } |  j | d ƒ d  S(   Nt   1t   2R!   R   (   R   R
   t
   writelinesR   R	   R   t   readR   (   R   t   lt   buf(    (    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_file.pyt   testWritelinesUserList?   s    c         C  s&   |  j  t |  j j d d d g ƒ d  S(   Ni   i   i   (   R   R*   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_file.pyt   testWritelinesIntegersH   s    c         C  s2   t  d d d g ƒ } |  j t |  j j | ƒ d  S(   Ni   i   i   (   R   R   R*   R
   R.   (   R   R0   (    (    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_file.pyt   testWritelinesIntegersUserListL   s    c         C  s<   d d d „  ƒ  Y} |  j  t |  j j | ƒ  | ƒ  g ƒ d  S(   Nt	   NonStringc           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    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_file.pyR5   S   s   (    (   R   R*   R
   R.   (   R   R5   (    (    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_file.pyt   testWritelinesNonStringQ   s    c         C  s‹   |  j  } |  j | j t ƒ |  j | j ƒ  ƒ |  j | j ƒ t | d ƒ rm |  j t	 t
 f | j d ƒ n  | j ƒ  |  j | j ƒ d  S(   NR#   t    (   R
   R   R   R   t   assertFalset   isattyR   R)   R   t   IOErrorR*   R#   R   t
   assertTrue(   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_file.pyt
   testErrorsY   s    	
c         C  si  d d f d d f d d f d d f d d f d d f d d f d	 d f d
 d f d d f d d f d g  f f d d f g } t  j j d ƒ s¦ | j d d f ƒ n  |  j j d  d  d  ƒ |  j |  j j ƒ x9 | D]1 \ } } t	 |  j | ƒ } |  j
 t | | Œ qÖ W|  j |  j j d  d  d  ƒ d  ƒ y d d Wn) |  j |  j j t  j ƒ  Œ  d  ƒ n Xd  S(   Nt   filenot   flushR;   t   nextR/   R   R9   t   readlinet	   readlinest   seeki    R   R.   t   __iter__t   atheost   truncatei   (    (    (    (    (    (   R9   (    (    (   i    (    (   R9   (    (    (   t   syst   platformt
   startswitht   appendR
   t   __exit__R   R=   R   R   R   t
   ValueErrorR   t   exc_info(   R   t   methodst
   methodnamet   argst   method(    (    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_file.pyt   testMethodsd   s2    											"c         C  s   |  j  t |  j j ƒ d  S(   N(   R   R<   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_file.pyt   testReadWhenWriting‡   s    (   R6   R7   R   R   R   R   R'   R+   R2   R3   R4   R8   R>   RS   RT   (    (    (    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_file.pyR      s   															#t   CAutoFileTestsc           B  s   e  Z e j Z RS(    (   R6   R7   t   ioR	   (    (    (    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_file.pyRU   Š   s   t   PyAutoFileTestsc           B  s   e  Z e e j ƒ Z RS(    (   R6   R7   t   staticmethodt   pyioR	   (    (    (    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_file.pyRW   �   s   t   OtherFileTestsc           B  s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C  s   t  j t ƒ d  S(   N(   R   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_file.pyR   “   s    c         C  sp   |  j  t d ƒ j ƒ  xS d D]K } y |  j  t | ƒ } Wn t k
 rL q X| j ƒ  |  j d | ƒ q Wd  S(   NR   R9   t   aUs   wU+s   %r is an invalid file mode(   R9   R[   s   wU+(   R	   R   R   RM   t   fail(   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_file.pyt   testModeStrings–   s    
c         C  sŸ   d } y |  j  t | ƒ } Wna t k
 r } | j d d k r› t | ƒ } t | k se | | k r| |  j d | ƒ q| q› n X| j ƒ  |  j d | ƒ d  S(   Nt   qwertyi    s&   bad error message for invalid mode: %ss   no error for invalid mode: %s(   R	   R   RM   RQ   t   strR\   R   (   R   t   bad_modeR
   t   msgt   s(    (    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_file.pyt   testBadModeArgument¢   s    
c         C  så   xÞ d	 D]Ö } y� |  j  t d | ƒ } | j t | ƒ j d ƒ ƒ | j ƒ  | j ƒ  |  j  t d | ƒ } t | j ƒ  j d ƒ ƒ } | j ƒ  | j ƒ  Wn0 t	 k
 rÌ } |  j
 d | t | ƒ f ƒ n X|  j | | ƒ q Wd  S(
   Niÿÿÿÿi    i   i   R   t   asciiR!   s    error setting buffer size %d: %s(   iÿÿÿÿi    i   i   (   R	   R   R   R_   t   encodeR   t   intR/   t   decodeR<   R\   R   (   R   Rb   R
   t   dRa   (    (    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_file.pyt   testSetBufferSize²   s    


!c         C  s  |  j  t d ƒ } zú | j d ƒ | j ƒ  |  j  t d ƒ } | j d ƒ } | d k rm |  j d | ƒ n  | j ƒ  d k r™ |  j d | j ƒ  ƒ n  | j ƒ  | j ƒ  d k rÏ |  j d | j ƒ  ƒ n  | j ƒ  t j	 j
 t ƒ } | d k r|  j d	 | ƒ n  Wd  | j ƒ  Xd  S(
   NR   t   12345678901s   rb+i   t   12345s(   Read on file opened for update failed %rs   File pos after read wrong %ds!   File pos after ftruncate wrong %ds"   File size after ftruncate wrong %d(   R	   R   R   R   R/   R\   R   RG   t   ost   patht   getsize(   R   R
   t   datat   size(    (    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_file.pyt   testTruncateOnWindowsÃ   s$    


c         C  s¥  d } d } | t  | ƒ s) t d ƒ ‚ | t  | ƒ } d d d d d d	 g } d
 d f d d f d d  f d t d d d ƒ f f g } |  j t d ƒ } | j | | ƒ | j | ƒ | j ƒ  x_ | D]W \ } } |  j t d ƒ }	 |  j t	 |	 ƒ | ƒ t
 |	 | ƒ }
 |
 | Œ  |	 j ƒ  qÌ W|  j t d ƒ }	 x t | ƒ D] } t	 |	 ƒ qFW| j d ƒ } y |	 j ƒ  } Wn t k
 r™|  j d ƒ n X| | k rÀ|  j d | | f ƒ n  | j d ƒ } t d d t  | ƒ ƒ } y |	 j | ƒ Wn t k
 r|  j d ƒ n X| j ƒ  } | | k rL|  j d | | f ƒ n  | j d ƒ } y |	 j t  | ƒ ƒ } Wn t k
 r”|  j d ƒ n X| | k r»|  j d | | f ƒ n  y |	 j ƒ  } Wn t k
 rë|  j d ƒ n X| | k r|  j d | | f ƒ n  |	 j ƒ  |  j t d ƒ }	 ze x |	 D] } q8Wy/ |	 j ƒ  |	 j | ƒ |	 j ƒ  |	 j ƒ  Wn t k
 r‘|  j d ƒ n XWd  |	 j ƒ  Xd  S(!   Ni @  s   ham
s*   dataoffset must be multiple of len(filler)s   spam, spam and eggs
s   eggs, spam, ham and spam
s   saussages, spam, spam and eggs
s   spam, ham, spam and eggs
s(   spam, spam, spam, spam, spam, ham, spam
s   wonderful spaaaaaam.
RB   R/   RC   R#   R   t    id   R   R!   i    sL   readline() after next() with supposedly empty iteration-buffer failed anywaysE   readline() after next() with empty buffer failed. Got %r, expected %rs    sL   readinto() after next() with supposedly empty iteration-buffer failed anywaysE   readinto() after next() with empty buffer failed. Got %r, expected %rsH   read() after next() with supposedly empty iteration-buffer failed anywaysA   read() after next() with empty buffer failed. Got %r, expected %rsM   readlines() after next() with supposedly empty iteration-buffer failed anywaysF   readlines() after next() with empty buffer failed. Got %r, expected %rs'   read* failed after next() consumed file(    (    (    (   t   lent   AssertionErrorR   R	   R   R   R.   R   R   RA   R   t   ranget   popRB   RM   R\   R#   R$   R/   RC   (   R   t
   dataoffsett   fillert   nchunkst	   testlinesRO   t   bagRP   RQ   R
   t   metht   it   testlinet   lineR1   t   lines(    (    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_file.pyt   testIterationß   s�    		

					


(   R6   R7   R   R]   Rc   Ri   Rq   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_file.pyRZ   ‘   s   					t   COtherFileTestsc           B  s   e  Z e j Z RS(    (   R6   R7   RV   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_file.pyR‚   ?  s   t   PyOtherFileTestsc           B  s   e  Z e e j ƒ Z RS(    (   R6   R7   RX   RY   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_file.pyRƒ   B  s   c           C  s   t  t t t t ƒ d  S(   N(   R   RU   RW   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_file.pyt	   test_mainF  s    	t   __main__(   t
   __future__R    RH   Rl   t   unittestR   t   weakrefR   RV   t   _pyioRY   t   test.supportR   R   t   testR   R   t   TestCaseR   RU   RW   RZ   R‚   Rƒ   R„   R6   (    (    (    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_file.pyt   <module>   s&   w®	