ó
|‰ãW½9  c           @€  s  d  d l  m Z d  d l Z d  d l j j Z d  d l Z d  d l	 Z	 d  d l
 Z
 e
 j j j d ƒ Z d  d l m Z e	 j d* k r› d „  Z d „  Z n d	 „  Z d
 „  Z d „  Z d d+ d „  ƒ  YZ d „  Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z d d, d „  ƒ  YZ d d- d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ  e d „  ƒ Z! d d. d  „  ƒ  YZ" d! „  Z# e d" „  ƒ Z$ e d# „  ƒ Z% e e
 j j j& d$ e' e( g ƒ d% „  ƒ ƒ Z) e
 j j j& d& d' d( g ƒ d) „  ƒ Z* d S(/   iÿÿÿÿ(   t   with_statementNs   not hasattr(os, 'dup')(   t   print_i   i    c         C€  s  t  |  t ƒ r! |  j d ƒ }  n  t  |  t ƒ } | sd d i d t j ƒ  k sa t j t  ƒ rp t j t  ƒ n d d 6d t j ƒ  k s˜ t j |  ƒ r§ t j |  ƒ n d d 6d t j ƒ  k sÏ t j t ƒ rÞ t j t ƒ n d d	 6t j | ƒ d
 6} t	 t j
 | ƒ ƒ ‚ n  d  } |  S(   Ns   UTF-8t    s5   assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}t
   isinstancet   py0t   objt   py1t   bytest   py2t   py4(   R   t   strt   encodeR   t   @py_builtinst   localst
   @pytest_art   _should_repr_global_namet	   _safereprt   AssertionErrort   _format_explanationt   None(   R   t   @py_assert3t   @py_format5(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   tobytes   s      Ã  c         C€  s  t  |  t ƒ r! t |  d ƒ }  n  t  |  t ƒ } | sd d i d t j ƒ  k sa t j t  ƒ rp t j t  ƒ n d d 6d t j ƒ  k s˜ t j |  ƒ r§ t j |  ƒ n d d 6d t j ƒ  k sÏ t j t ƒ rÞ t j t ƒ n d d	 6t j | ƒ d
 6} t t j	 | ƒ ƒ ‚ n  d  } |  S(   Ns   UTF-8R   s5   assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}R   R   R   R   R
   R   R	   (   R   R   R
   R   R   R   R   R   R   R   R   (   R   R   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   totext   s      Ã  c         C€  s  t  |  t ƒ r! |  j d ƒ }  n  t  |  t ƒ } | sd d i d t j ƒ  k sa t j t  ƒ rp t j t  ƒ n d d 6d t j ƒ  k s˜ t j |  ƒ r§ t j |  ƒ n d d 6d t j ƒ  k sÏ t j t ƒ rÞ t j t ƒ n d d	 6t j | ƒ d
 6} t	 t j
 | ƒ ƒ ‚ n  d  } |  S(   Ns   UTF-8R   s5   assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}R   R   R   R   R
   R   R	   (   R   t   unicodeR   R
   R   R   R   R   R   R   R   R   (   R   R   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR      s      Ã  c         C€  s  t  |  t ƒ r! t |  d ƒ }  n  t  |  t ƒ } | sd d i d t j ƒ  k sa t j t  ƒ rp t j t  ƒ n d d 6d t j ƒ  k s˜ t j |  ƒ r§ t j |  ƒ n d d 6d t j ƒ  k sÏ t j t ƒ rÞ t j t ƒ n d d	 6t j | ƒ d
 6} t t j	 | ƒ ƒ ‚ n  d  } |  S(   Ns   UTF-8R   s5   assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}R   R   R   R   R   R   R	   (   R   R
   R   R   R   R   R   R   R   R   R   (   R   R   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR      s      Ã  c         C€  s   t  j |  t | ƒ ƒ d  S(   N(   t   ost   writeR   (   t   fdR   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   oswritebytes!   s    t
   TestTextIOc           B€  s   e  Z d  „  Z d „  Z RS(   c         C€  sí   t  j j ƒ  } | j d ƒ | j ƒ  } d } | | k } | sÕ t j d
 | f d | | f ƒ i d t j ƒ  k s‚ t j	 | ƒ r‘ t j
 | ƒ n d d 6t j
 | ƒ d 6} d i | d	 6} t t j | ƒ ƒ ‚ n  d  } } | j ƒ  d  S(   Nt   hellos   ==s   %(py0)s == %(py3)st   sR   t   py3R   s   assert %(py5)st   py5(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   t   pyt   iot   TextIOR   t   getvalueR   t   _call_reprcompareR   R   R   R   R   R   R   t   close(   t   selft   fR   t   @py_assert2t   @py_assert1t   @py_format4t   @py_format6(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt	   test_text%   s       l   
c         C€  st  t  j j ƒ  } t j d k rA | j d ƒ t  j j t d ƒ n/| j t	 d d ƒ ƒ | j d ƒ | j
 ƒ  } | j ƒ  t | t	 ƒ } | sjd d i d	 t j ƒ  k sº t j t ƒ rÉ t j t ƒ n d	 d
 6d t j ƒ  k sñ t j | ƒ r t j | ƒ n d d 6d t j ƒ  k s(t j t	 ƒ r7t j t	 ƒ n d d 6t j | ƒ d 6} t t j | ƒ ƒ ‚ n  d  } d  S(   Ni   i    s   \u00f6s    f.write(bytes('hello', 'UTF-8'))s   UTF-8R   R   s5   assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}R   R   R   R   R   R   R	   (   i   i    (   R"   R#   R$   t   syst   version_infoR   t   testt   raisest	   TypeErrorR   R%   R'   R   R   R   R   R   R   R   R   R   (   R(   R)   R   R   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_unicode_and_str_mixture,   s    
  Ã  (   t   __name__t
   __module__R.   R4   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR   $   s   	c          C€  sS  t  j j ƒ  }  |  j t d ƒ ƒ t  j j t d ƒ |  j ƒ  } d } t | ƒ } | | k } | sAt	 j
 d | f d | | f ƒ i d t j ƒ  k s§ t	 j | ƒ r¶ t	 j | ƒ n d d 6d t j ƒ  k sÞ t	 j t ƒ rí t	 j t ƒ n d d 6t	 j | ƒ d	 6t	 j | ƒ d
 6} d i | d 6} t t	 j | ƒ ƒ ‚ n  d  } } } d  S(   NR   s   f.write(totext('hello'))s   ==s0   %(py0)s == %(py6)s
{%(py6)s = %(py2)s(%(py4)s)
}R   R   R   R   R	   t   py6R   s   assert %(py8)st   py8(   s   ==(   s0   %(py0)s == %(py6)s
{%(py6)s = %(py2)s(%(py4)s)
}s   assert %(py8)s(   R"   R#   t   BytesIOR   R   R1   R2   R3   R%   R   R&   R   R   R   R   R   R   R   (   R)   R   R   t   @py_assert5R+   t   @py_format7t   @py_format9(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_bytes_io8   s        ³   c          C€  s)  d d l  m }  |  ƒ  } | j } | ƒ  } | } | sµ d d i d t j ƒ  k sc t j | ƒ rr t j | ƒ n d d 6t j | ƒ d 6t j | ƒ d 6} t t j	 | ƒ ƒ ‚ n  d  } } } t j j t | j ƒ t j j t | j ƒ t j j t t | ƒ t j j t | j ƒ | j ƒ  d  S(	   Niÿÿÿÿ(   t   DontReadFromInputR   sE   assert not %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.isatty
}()
}R)   R   R   R	   (   t   py._io.captureR>   t   isattyR   R   R   R   R   R   R   R   R"   R1   R2   t   IOErrort   readt	   readlinest   itert
   ValueErrort   filenoR'   (   R>   R)   R+   R   R:   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_dontreadfrominput?   s    		 	   e  c         C€  s;   |  j  d ƒ } | j d ƒ j d ƒ } |  j | j ƒ | S(   Nt   testdirR   s   wb+(   t   getfuncargvaluet
   makepyfilet   opent   addfinalizerR'   (   t   requestRH   R)   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   pytest_funcarg__tmpfileI   s    c         C€  s¨  g  } x?t  d ƒ D]1} t j j |  d d ƒ} | |  k } | sÿ t j d! | f d" | |  f ƒ i d t j ƒ  k s… t j | ƒ r” t j	 | ƒ n d d 6d t j ƒ  k s¼ t j |  ƒ rË t j	 |  ƒ n d d	 6} d# i | d 6} t
 t j | ƒ ƒ ‚ n  d  } | j } | ƒ  } |  j } | ƒ  }	 | |	 k }
 |
 s7t j d$ |
 f d% | |	 f ƒ i t j	 | ƒ d 6d t j ƒ  k st j | ƒ rœt j	 | ƒ n d d 6t j	 | ƒ d	 6t j	 | ƒ d 6d t j ƒ  k sät j |  ƒ rót j	 |  ƒ n d d 6t j	 |	 ƒ d 6} d& i | d 6} t
 t j | ƒ ƒ ‚ n  d  } } }
 } }	 | | k } | st j d' | f d( | | f ƒ i d t j ƒ  k s¡t j | ƒ r°t j	 | ƒ n d d 6d t j ƒ  k sØt j | ƒ rçt j	 | ƒ n d d	 6} d) i | d 6} t
 t j | ƒ ƒ ‚ n  d  } t | d d
 d | ƒ| j | ƒ q Wx( t  d ƒ D] } | | } | j ƒ  qUW|  j d ƒ |  j ƒ  } d } t | ƒ }
 | |
 k } | sŒt j d* | f d+ | |
 f ƒ i t j	 | ƒ d 6d t j ƒ  k st j t ƒ rt j	 t ƒ n d d 6d t j ƒ  k s9t j | ƒ rHt j	 | ƒ n d d 6t j	 |
 ƒ d 6} d, i | d 6} t
 t j | ƒ ƒ ‚ n  d  } } }
 |  j ƒ  d  S(-   Ni   t   encodings   utf-8s   !=s   %(py0)s != %(py2)st   nfR   t   tmpfileR   R   s   assert %(py4)sR	   sz   %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.fileno
}()
} != %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s.fileno
}()
}R8   R7   t   py10s   assert %(py12)st   py12s   not ins   %(py0)s not in %(py2)st   flistt   endt   filei    t   01234t   ins0   %(py1)s in %(py6)s
{%(py6)s = %(py3)s(%(py4)s)
}R   t   reprR    R   s   assert %(py8)s(   s   !=(   s   %(py0)s != %(py2)ss   assert %(py4)s(   s   !=(   sz   %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.fileno
}()
} != %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s.fileno
}()
}s   assert %(py12)s(   s   not in(   s   %(py0)s not in %(py2)ss   assert %(py4)s(   RX   (   s0   %(py1)s in %(py6)s
{%(py6)s = %(py3)s(%(py4)s)
}s   assert %(py8)s(   t   rangeR"   R#   t   dupfileR   R&   R   R   R   R   R   R   R   RF   R   t   appendR'   t   seekRB   RY   (   RQ   RT   t   iRP   R+   t   @py_format3R   R   t   @py_assert7t   @py_assert9R:   t   @py_format11t   @py_format13R)   R   t   @py_assert0R*   R;   R<   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_dupfileO   sR      “   	 	 	 	   Ó     “   
    ³   c          C€  sÂ  d t  f d „  ƒ  Y}  |  ƒ  } t j } | j } | | ƒ } | | k } | r}t j d f | f d f | | f ƒ i d t j ƒ  k p• t j | ƒ r§ t j	 | ƒ n d d 6d t j ƒ  k pÌ t j t ƒ rÞ t j	 t ƒ n d d 6t j	 | ƒ d	 6t j	 | ƒ d
 6d t j ƒ  k p#t j | ƒ r5t j	 | ƒ n d d 6t j	 | ƒ d 6} d d i | d 6} t
 t j | ƒ ƒ ‚ n  t } } } } t j j t ƒ  t j j | d t ƒWd QXd S(   sT   
    dupfile should trap an AttributeError and return f if no mode is supplied.
    t   SomeFileWrapperc           B€  s   e  Z d  Z d „  Z RS(   s4   An object with a fileno method but no mode attributec         S€  s   d S(   Ni   (    (   R(   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyRF   g   s    (   R5   R6   t   __doc__RF   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyRf   e   s   t   isse   %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.io
}.dupfile
}(%(py5)s)
} is %(py9)sRQ   t   py9R"   R   R   R	   R!   t   py7R   s   assert %(py11)st   py11t   raisingN(   t   objectR"   R#   R[   R   R&   R   R   R   R   R   R   R   R1   R2   t   AttributeErrort   True(   Rf   RQ   R+   R   t   @py_assert6t   @py_assert8t   @py_format10t   @py_format12(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_dupfile_no_modea   s    		 	    ÿ    c         C€  så  t  j ƒ  } y t j j d | ƒ } Wn* t j j j k
 rR t j j d ƒ n X|  ƒ  t j j d | ƒ } t g  | j	 d ƒ D] } d | k rƒ | ^ qƒ ƒ } t g  | j	 d ƒ D] } d | k r· | ^ q· ƒ } d } | | } | | k  }	 |	 sÓt
 j d |	 f d | | f ƒ i d t j ƒ  k s<t
 j | ƒ rKt
 j | ƒ n d d	 6d
 t j ƒ  k sst
 j | ƒ r‚t
 j | ƒ n d
 d 6t
 j | ƒ d 6}
 t
 j | ƒ d i |
 d 6} t t
 j | ƒ ƒ ‚ n  d  }	 } } d  S(   Ns
   lsof -p %ds   could not run 'lsof's   
t   REGi   t   <s   %(py0)s < (%(py2)s + %(py4)s)t   len2R   t   len1R   R	   s   
>assert %(py7)sRj   (   Rv   (   s   %(py0)s < (%(py2)s + %(py4)s)(   R   t   getpidR"   t   processt   cmdexect   ErrorR1   t   skipt   lent   splitR   R&   R   R   R   R   t   _format_assertmsgR   R   R   (   t   funct   pidt   outt   out2t   xRx   Rw   R   R:   R+   R-   t   @py_format8(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt
   lsof_checkn   s"    44 
   £   t   TestFDCapturec           B€  sV   e  Z e Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(   c         C€  sÉ  | j  ƒ  } t j j | d t ƒ} t d ƒ } t j | | ƒ | j ƒ  } | j	 ƒ  } | } | s¾ d i d t
 j ƒ  k sŒ t j | ƒ r› t j | ƒ n d d 6} t t j | ƒ ƒ ‚ n  d  } t j j | d t ƒ} | j ƒ  t j | | ƒ | j ƒ  } | j	 ƒ  } d }	 | |	 k } | s»t j d | f d | |	 f ƒ i d t
 j ƒ  k sht j | ƒ rwt j | ƒ n d d 6t j |	 ƒ d	 6}
 d i |
 d 6} t t j | ƒ ƒ ‚ n  d  } }	 d  S(   Nt   nowR   R   s   assert not %(py0)sR   R   s   ==s   %(py0)s == %(py3)sR    s   assert %(py5)sR!   s   assert not %(py0)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   RF   R"   R#   t	   FDCapturet   FalseR   R   R   t   doneRB   R   R   R   R   R   R   R   R   t   startR&   (   R(   RQ   R   t   capt   dataR)   R   R+   t   @py_format2R*   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_not_now}   s.      A  
   l   c         C€  s  | j  ƒ  } t j j | ƒ } t d ƒ } t j | | ƒ | j ƒ  } | j ƒ  } d } | | k } | sÿ t	 j
 d
 | f d | | f ƒ i d t j ƒ  k s¬ t	 j | ƒ r» t	 j | ƒ n d d 6t	 j | ƒ d 6}	 d i |	 d	 6}
 t t	 j |
 ƒ ƒ ‚ n  d  } } | j ƒ  d  S(   NR   s   ==s   %(py0)s == %(py3)sR   R   R    R   s   assert %(py5)sR!   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   RF   R"   R#   RŠ   R   R   R   RŒ   RB   R   R&   R   R   R   R   R   R   R   R'   (   R(   RQ   R   RŽ   R   R)   R   R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_simpleŒ   s       l   
c         C€  s(   x! t  d ƒ D] } |  j | ƒ q Wd  S(   Ni
   (   RZ   R’   (   R(   RQ   R^   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_simple_many–   s    c         €  s   t  ‡  ‡ f d †  ƒ d  S(   Nc           €  s   ˆ  j  ˆ ƒ S(   N(   R“   (    (   R(   RQ   (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   <lambda>›   s    (   R‡   (   R(   RQ   (    (   R(   RQ   s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt!   test_simple_many_check_open_filesš   s    c         C€  sN   | j  ƒ  } t j j | ƒ } | j ƒ  } t j j t | j ƒ | j	 ƒ  d  S(   N(
   RF   R"   R#   RŠ   RŒ   R1   R2   RE   R   R'   (   R(   RQ   R   RŽ   R)   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_simple_fail_second_start   s
    c         C€  sþ   t  j j d d t ƒ} t d d t j ƒ| j ƒ  } | j ƒ  } d } | | k } | sð t	 j
 d | f d | | f ƒ i d t j ƒ  k s t	 j | ƒ r¬ t	 j | ƒ n d d	 6t	 j | ƒ d
 6} d i | d 6} t t	 j | ƒ ƒ ‚ n  d  } } d  S(   Ni   t   patchsysR   RV   s   hello
s   ==s   %(py0)s == %(py3)sR   R   R    R   s   assert %(py5)sR!   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R"   R#   RŠ   Ro   R   R/   t   stderrRŒ   RB   R   R&   R   R   R   R   R   R   R   (   R(   RŽ   R)   R   R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_stderr¤   s       l   c   
      C€  sn  | j  t d ƒ ƒ | j d ƒ t j j d d | ƒ} t j d d ƒ j ƒ  } | j	 ƒ  } d } t | ƒ } | | k } | s\t
 j d | f d | | f ƒ i d t j ƒ  k sÂ t
 j | ƒ rÑ t
 j | ƒ n d d 6d	 t j ƒ  k sù t
 j t ƒ rt
 j t ƒ n d	 d
 6t
 j | ƒ d 6t
 j | ƒ d 6} d i | d 6}	 t t
 j |	 ƒ ƒ ‚ n  d  } } } d  S(   Nt   3i    RQ   id   s   ==s0   %(py0)s == %(py6)s
{%(py6)s = %(py2)s(%(py4)s)
}R…   R   R   R   R	   R7   R   s   assert %(py8)sR8   (   s   ==(   s0   %(py0)s == %(py6)s
{%(py6)s = %(py2)s(%(py4)s)
}s   assert %(py8)s(   R   R   R]   R"   R#   RŠ   R   RB   t   stripRŒ   R   R&   R   R   R   R   R   R   R   (
   R(   RQ   RŽ   R…   R)   R   R:   R+   R;   R<   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt
   test_stdin«   s        ³   c         C€  s  t  d ƒ t  d ƒ } } z6 t j j | j ƒ  ƒ } | j | ƒ | j | ƒ Wd  | j ƒ  X| j ƒ  } | j	 ƒ  } t
 | ƒ } | | k } | s–t j d | f d | | f ƒ i d t j ƒ  k sÕ t j | ƒ rä t j | ƒ n d d 6d t j ƒ  k st j t
 ƒ rt j t
 ƒ n d d 6d	 t j ƒ  k sCt j | ƒ rRt j | ƒ n d	 d
 6t j | ƒ d 6}	 d i |	 d 6}
 t t j |
 ƒ ƒ ‚ n  d  } } t | j d ƒ j	 ƒ  } | | k } | s†t j d | f d | | f ƒ i d t j ƒ  k st j | ƒ rt j | ƒ n d d 6d t j ƒ  k sCt j | ƒ rRt j | ƒ n d d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } d  S(   Nt   foot   bars   ==s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}t   scapR   R   R   t   data1R    R!   R   s   assert %(py7)sRj   t   rbs   %(py0)s == %(py2)st   stmpt   data2s   assert %(py4)sR	   (   s   ==(   s0   %(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}s   assert %(py7)s(   s   ==(   s   %(py0)s == %(py2)ss   assert %(py4)s(   R   R"   R#   RŠ   RF   R   t   writeorgR'   RŒ   RB   R   R   R&   R   R   R   R   R   R   R   RK   t   name(   R(   RQ   R    R£   RŽ   R)   RŸ   t   @py_assert4R+   R-   R†   R¢   R_   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_writeorgµ   s,       Ú   
  “   (   R5   R6   t   needsdupt
   pytestmarkR‘   R’   R“   R•   R–   R™   Rœ   R§   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyRˆ   z   s   		
					
t   TestStdCapturec           B€  sª   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z e j j	 j
 d d d ƒd „  ƒ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         K€  s   t  j j |   S(   N(   R"   R#   t
   StdCapture(   R(   t   kw(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt
   getcaptureÅ   s    c   	      C€  sÈ  |  j  ƒ  } t j j d ƒ t j j d ƒ | j ƒ  \ } } | j ƒ  } d } | | k } | s÷ t j d | f d | | f ƒ i d t	 j
 ƒ  k s¤ t j | ƒ r³ t j | ƒ n d d 6t j | ƒ d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  d  } } | j ƒ  } d } | | k } | sºt j d | f d | | f ƒ i d t	 j
 ƒ  k sgt j | ƒ rvt j | ƒ n d d 6t j | ƒ d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  d  } } d  S(   NR   t   worlds   ==s   %(py0)s == %(py3)sR   R   R    R   s   assert %(py5)sR!   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R­   R/   t   stdoutR   R˜   RŒ   RB   R   R&   R   R   R   R   R   R   R   (	   R(   RŽ   t   outfilet   errfileR   R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_capturing_done_simpleÈ   s(       l   
   l   c         C€  s¥  |  j  ƒ  } d GHt j j d ƒ | j ƒ  \ } } d } | | k } | sà t j d | f d | | f ƒ i d t j ƒ  k s t j	 | ƒ rœ t j
 | ƒ n d d 6t j
 | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } d } | | k } | s—t j d | f d | | f ƒ i d t j ƒ  k sDt j	 | ƒ rSt j
 | ƒ n d d 6t j
 | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } d  S(   Ns   hello worlds   hello error
s   hello world
s   ==s   %(py0)s == %(py3)sRƒ   R   R    R   s   assert %(py5)sR!   t   err(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R­   R/   R˜   R   t   resetR   R&   R   R   R   R   R   R   R   (   R(   RŽ   Rƒ   R³   R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_capturing_reset_simpleÒ   s$       l   
   l   c         C€  s†  |  j  ƒ  } z©d GHt j j d ƒ | j ƒ  \ } } d } | | k } | sã t j d | f d | | f ƒ i d t j ƒ  k s t j	 | ƒ rŸ t j
 | ƒ n d d 6t j
 | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } d } | | k } | sšt j d | f d | | f ƒ i d t j ƒ  k sGt j	 | ƒ rVt j
 | ƒ n d d 6t j
 | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } t j j d ƒ Wd  | j ƒ  \ } } Xd } | | k } | sxt j d | f d | | f ƒ i d t j ƒ  k s%t j	 | ƒ r4t j
 | ƒ n d d 6t j
 | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } d  S(   Ns   hello worlds   hello error
s   hello world
s   ==s   %(py0)s == %(py3)sRƒ   R   R    R   s   assert %(py5)sR!   R³   t   error2(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R­   R/   R˜   R   t
   readouterrR   R&   R   R   R   R   R   R   R   R´   (   R(   RŽ   Rƒ   R³   R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_capturing_readouterrÚ   s8       l   
   l   
   l   c         C€  sŒ  |  j  ƒ  } d GH| j ƒ  \ } } t j } | j } d } d } | | | ƒ } | | k }	 |	 snt j d |	 f d | | f ƒ i t j | ƒ d 6d t j	 ƒ  k s´ t j
 | ƒ rÃ t j | ƒ n d d 6d	 t j	 ƒ  k së t j
 t ƒ rú t j t ƒ n d	 d
 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d 6}
 d i |
 d 6} t t j | ƒ ƒ ‚ n  d  }	 } } } } } d  S(   Ns   hxÄ…Ä‡s   hxÄ…Ä‡
t   utf8s   ==sv   %(py0)s == %(py12)s
{%(py12)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.builtin
}._totext
}(%(py8)s, %(py10)s)
}R8   Rƒ   R   R"   R   R	   R7   RS   RR   R   s   assert %(py14)st   py14(   s   ==(   sv   %(py0)s == %(py12)s
{%(py12)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.builtin
}._totext
}(%(py8)s, %(py10)s)
}s   assert %(py14)s(   R­   R·   R"   t   builtint   _totextR   R&   R   R   R   R   R   R   R   (   R(   RŽ   Rƒ   R³   R   R:   R`   Ra   t   @py_assert11R+   Rc   t   @py_format15(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt!   test_capturing_readouterr_unicodeç   s    	 	      ã   s   sys.version_info >= (3,)t   reasons*   text output different for bytes on python3c         C€  sŒ  |  j  ƒ  } d GH| j ƒ  \ } } t j } | j } d } d } | | | ƒ } | | k }	 |	 snt j d |	 f d | | f ƒ i t j | ƒ d 6d t j	 ƒ  k s´ t j
 | ƒ rÃ t j | ƒ n d d 6d	 t j	 ƒ  k së t j
 t ƒ rú t j t ƒ n d	 d
 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d 6}
 d i |
 d 6} t t j | ƒ ƒ ‚ n  d  }	 } } } } } d  S(   Ns   ¦s   \ufffd
s   unicode-escapes   ==sv   %(py0)s == %(py12)s
{%(py12)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.builtin
}._totext
}(%(py8)s, %(py10)s)
}R8   Rƒ   R   R"   R   R	   R7   RS   RR   R   s   assert %(py14)sRº   (   s   ==(   sv   %(py0)s == %(py12)s
{%(py12)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.builtin
}._totext
}(%(py8)s, %(py10)s)
}s   assert %(py14)s(   R­   R·   R"   R»   R¼   R   R&   R   R   R   R   R   R   R   (   R(   RŽ   Rƒ   R³   R   R:   R`   Ra   R½   R+   Rc   R¾   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt/   test_capturing_readouterr_decode_error_handlingí   s    	 	      ã   c         C€  sµ  |  j  d t ƒ } t j j d ƒ t j j d ƒ t j j d ƒ | j ƒ  \ } } | j } | ƒ  } d } | | k } | s3t j	 d | f d | | f ƒ i d t
 j ƒ  k sÀ t j | ƒ rÏ t j | ƒ n d d	 6t j | ƒ d
 6t j | ƒ d 6t j | ƒ d 6} d i | d 6}	 t t j |	 ƒ ƒ ‚ n  d  } } } } | } | s«d i d t
 j ƒ  k syt j | ƒ rˆt j | ƒ n d d	 6}
 t t j |
 ƒ ƒ ‚ n  d  } d  S(   Nt   mixeds   hello R®   t   .s   hello world.s   ==sD   %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.strip
}()
} == %(py7)sRƒ   R   R   R	   Rj   R   s   assert %(py9)sRi   s   assert not %(py0)sR³   (   s   ==(   sD   %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.strip
}()
} == %(py7)ss   assert %(py9)ss   assert not %(py0)s(   R­   Ro   R/   R¯   R   R˜   R´   R›   R   R&   R   R   R   R   R   R   R   (   R(   RŽ   Rƒ   R³   R+   R   Rp   R:   R†   Rr   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_capturing_mixedö   s&    	 	    Œ     A  c   	      C€  s`  |  j  ƒ  } d GH| j ƒ  \ } } t j j t | j ƒ d } | | k } | sæ t j d | f d | | f ƒ i d t j	 ƒ  k s“ t j
 | ƒ r¢ t j | ƒ n d d 6t j | ƒ d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  d  } } | } | sVd i d t j	 ƒ  k s$t j
 | ƒ r3t j | ƒ n d d 6} t t j | ƒ ƒ ‚ n  d  } d  S(   NR   s   hello
s   ==s   %(py0)s == %(py3)sRƒ   R   R    R   s   assert %(py5)sR!   s   assert not %(py0)sR³   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)ss   assert not %(py0)s(   R­   R´   R"   R1   R2   RE   R   R&   R   R   R   R   R   R   R   (	   R(   RŽ   Rƒ   R³   R*   R+   R,   R-   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_reset_twice_errorÿ   s        l   
  A  c         C€  sÝ  t  j } t  j } |  j ƒ  } t  j j d ƒ t  j j d ƒ t j j ƒ  t  _ t j j ƒ  t  _ d GHt  j j d ƒ | j ƒ  \ } } d } | | k } | s6t	 j
 d | f d | | f ƒ i d t j ƒ  k sã t	 j | ƒ rò t	 j | ƒ n d d 6t	 j | ƒ d	 6} d i | d 6}	 t t	 j |	 ƒ ƒ ‚ n  d  } } d } | | k } | sít	 j
 d | f d | | f ƒ i d t j ƒ  k sšt	 j | ƒ r©t	 j | ƒ n d d 6t	 j | ƒ d	 6} d i | d 6}	 t t	 j |	 ƒ ƒ ‚ n  d  } } t  j } | | k }
 |
 sÞt	 j
 d |
 f d | | f ƒ i d t j ƒ  k sTt	 j t  ƒ rct	 j t  ƒ n d d 6t	 j | ƒ d 6d t j ƒ  k s›t	 j | ƒ rªt	 j | ƒ n d d 6} d i | d 6} t t	 j | ƒ ƒ ‚ n  d  } }
 t  j } | | k }
 |
 sÏt	 j
 d  |
 f d! | | f ƒ i d t j ƒ  k sEt	 j t  ƒ rTt	 j t  ƒ n d d 6t	 j | ƒ d 6d t j ƒ  k sŒt	 j | ƒ r›t	 j | ƒ n d d 6} d" i | d 6} t t	 j | ƒ ƒ ‚ n  d  } }
 d  S(#   NR   R®   s   not seens	   not seen
s   ==s   %(py0)s == %(py3)sRƒ   R   R    R   s   assert %(py5)sR!   R³   s.   %(py2)s
{%(py2)s = %(py0)s.stdout
} == %(py4)sR/   R   t   oldoutR	   s   assert %(py6)sR7   s.   %(py2)s
{%(py2)s = %(py0)s.stderr
} == %(py4)st   olderr(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s.   %(py2)s
{%(py2)s = %(py0)s.stdout
} == %(py4)ss   assert %(py6)s(   s   ==(   s.   %(py2)s
{%(py2)s = %(py0)s.stderr
} == %(py4)ss   assert %(py6)s(   R/   R¯   R˜   R­   R   R"   R#   R$   R´   R   R&   R   R   R   R   R   R   R   (   R(   RÆ   RÇ   RŽ   Rƒ   R³   R*   R+   R,   R-   R   R   R;   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt*   test_capturing_modify_sysouterr_in_between  sL    		   l   
   l   
	   £   
	   £   c         C€  s¸  |  j  ƒ  } d GH|  j  ƒ  } d GH| j ƒ  \ } } | j ƒ  \ } } d } | | k } | só t j d | f d | | f ƒ i d t j ƒ  k s  t j | ƒ r¯ t j | ƒ n d d 6t j | ƒ d 6}	 d i |	 d 6}
 t t j	 |
 ƒ ƒ ‚ n  d  } } d } | | k } | sªt j d | f d | | f ƒ i d t j ƒ  k sWt j | ƒ rft j | ƒ n d d 6t j | ƒ d 6}	 d i |	 d 6}
 t t j	 |
 ƒ ƒ ‚ n  d  } } d  S(   Nt   cap1t   cap2s   cap1
s   ==s   %(py0)s == %(py3)st   out1R   R    R   s   assert %(py5)sR!   s   cap2
R„   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R­   R´   R   R&   R   R   R   R   R   R   R   (   R(   RÉ   RÊ   R„   t   err2RË   t   err1R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_capturing_error_recursive  s(       l   
   l   c   	      C€  sq  |  j  d t d t ƒ } t j j d ƒ t j j d ƒ | j ƒ  \ } } d } | | k } | s÷ t j	 d | f d | | f ƒ i d t
 j ƒ  k s¤ t j | ƒ r³ t j | ƒ n d d 6t j | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } | } | sgd i d t
 j ƒ  k s5t j | ƒ rDt j | ƒ n d d 6} t t j | ƒ ƒ ‚ n  d  } d  S(   NRƒ   R³   R   R®   s   ==s   %(py0)s == %(py3)sR   R    R   s   assert %(py5)sR!   s   assert not %(py0)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)ss   assert not %(py0)s(   R­   Ro   R‹   R/   R¯   R   R˜   R´   R   R&   R   R   R   R   R   R   R   (	   R(   RŽ   Rƒ   R³   R*   R+   R,   R-   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_just_out_capture!  s        l   
  A  c   	      C€  sq  |  j  d t d t ƒ } t j j d ƒ t j j d ƒ | j ƒ  \ } } d } | | k } | s÷ t j	 d | f d | | f ƒ i d t
 j ƒ  k s¤ t j | ƒ r³ t j | ƒ n d d 6t j | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } | } | sgd i d t
 j ƒ  k s5t j | ƒ rDt j | ƒ n d d 6} t t j | ƒ ƒ ‚ n  d  } d  S(   NRƒ   R³   R   R®   s   ==s   %(py0)s == %(py3)sR   R    R   s   assert %(py5)sR!   s   assert not %(py0)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)ss   assert not %(py0)s(   R­   R‹   Ro   R/   R¯   R   R˜   R´   R   R&   R   R   R   R   R   R   R   (	   R(   RŽ   Rƒ   R³   R*   R+   R,   R-   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_just_err_capture)  s        l   
  A  c   
      C€  s  t  j } |  j d t ƒ } t  j } | j ƒ  \ } } t  j } | | k } | st j d | f d | | f ƒ i d t j ƒ  k s“ t j	 | ƒ r¢ t j
 | ƒ n d d 6d t j ƒ  k sÊ t j	 t  ƒ rÙ t j
 t  ƒ n d d 6t j
 | ƒ d 6} d i | d 6}	 t t j |	 ƒ ƒ ‚ n  d  } } t  j } | | k } | st j d | f d | | f ƒ i d t j ƒ  k s„t j	 t  ƒ r“t j
 t  ƒ n d d 6t j
 | ƒ d 6d t j ƒ  k sËt j	 | ƒ rÚt j
 | ƒ n d d 6} d i | d 6}	 t t j |	 ƒ ƒ ‚ n  d  } } d  S(   Nt   in_s   !=s-   %(py0)s != %(py4)s
{%(py4)s = %(py2)s.stdin
}t   newstdinR   R/   R   R	   R   s   assert %(py6)sR7   Rh   s-   %(py2)s
{%(py2)s = %(py0)s.stdin
} is %(py4)st   old(   s   !=(   s-   %(py0)s != %(py4)s
{%(py4)s = %(py2)s.stdin
}s   assert %(py6)s(   Rh   (   s-   %(py2)s
{%(py2)s = %(py0)s.stdin
} is %(py4)ss   assert %(py6)s(   R/   t   stdinR­   Ro   R´   R   R&   R   R   R   R   R   R   R   (
   R(   RÓ   RŽ   RÒ   Rƒ   R³   R   R+   R   R;   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_stdin_restored1  s$    			   £   
	   £   c         C€  sD   d GHd GHd GH|  j  ƒ  } t j j t d ƒ | j ƒ  \ } } d  S(   Ns/   XXX this test may well hang instead of crashings8   XXX which indicates an error in the underlying capturings   XXX mechanismss   sys.stdin.read()(   R­   R"   R1   R2   RA   R´   (   R(   RŽ   Rƒ   R³   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_stdin_nulled_by_default9  s    c   	      C€  sÝ  |  j  d t d t d t ƒ } z‚d GHt j j d ƒ | j ƒ  \ } } d } | | k } | sõ t j d | f d | | f ƒ i d t	 j
 ƒ  k s¢ t j | ƒ r± t j | ƒ n d d	 6t j | ƒ d
 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } | } | sed i d t	 j
 ƒ  k s3t j | ƒ rBt j | ƒ n d d	 6} t t j | ƒ ƒ ‚ n  d  } d GHt j j d ƒ | j ƒ  d GHt j j d ƒ Wd  | j ƒ  \ } } Xd } | | k } | sct j d | f d | | f ƒ i d t	 j
 ƒ  k st j | ƒ rt j | ƒ n d d	 6t j | ƒ d
 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } | } | sÓd i d t	 j
 ƒ  k s¡t j | ƒ r°t j | ƒ n d d	 6} t t j | ƒ ƒ ‚ n  d  } d  S(   NRƒ   R³   RÑ   R   s   error
s   hello
s   ==s   %(py0)s == %(py3)sR   R    R   s   assert %(py5)sR!   s   assert not %(py0)ss
   in betweens   in between
t   afters   error_after
s   after
(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)ss   assert not %(py0)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)ss   assert not %(py0)s(   R­   Ro   R‹   R/   R˜   R   t   suspendR   R&   R   R   R   R   R   R   R   t   resumeR´   (	   R(   RŽ   Rƒ   R³   R*   R+   R,   R-   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_suspend_resumeA  sF       l   
  A  
   l   
  A  (   R5   R6   R­   R²   Rµ   R¸   R¿   R"   R1   t   markt   skipifRÁ   RÄ   RÅ   RÈ   RÎ   RÏ   RÐ   RÕ   RÖ   RÚ   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyRª   Ä   s    		
								
				t   TestStdCaptureNotNowc           B€  s   e  Z d  „  Z RS(   c         K€  s*   t  | d <t j j |   } | j ƒ  | S(   NR‰   (   R‹   R"   R#   R«   t   startall(   R(   R¬   RŽ   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR­   T  s    

(   R5   R6   R­   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyRÝ   S  s   t   TestStdCaptureFDc           B€  s2   e  Z e Z d  „  Z d „  Z d „  Z d „  Z RS(   c         K€  s   t  j j |   S(   N(   R"   R#   t   StdCaptureFD(   R(   R¬   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR­   ]  s    c         C€  s  |  j  ƒ  } t d d ƒ t j j t d ƒ ƒ t j j ƒ  t d d ƒ t d d ƒ t j j d ƒ t j j ƒ  t d d ƒ | j ƒ  \ } } d } | | k } | s?t	 j
 d | f d | | f ƒ i d t j ƒ  k sì t	 j | ƒ rû t	 j | ƒ n d d 6t	 j | ƒ d 6} d i | d 6} t t	 j | ƒ ƒ ‚ n  d  } } d } | | k } | söt	 j
 d | f d | | f ƒ i d t j ƒ  k s£t	 j | ƒ r²t	 j | ƒ n d d 6t	 j | ƒ d 6} d i | d 6} t t	 j | ƒ ƒ ‚ n  d  } } d  S(   Ni   t   1i   Rš   t   at   bt   ct   123s   ==s   %(py0)s == %(py3)sRƒ   R   R    R   s   assert %(py5)sR!   t   abcR³   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R­   R   R/   R¯   R   R
   t   flushR˜   R´   R   R&   R   R   R   R   R   R   R   (   R(   RŽ   Rƒ   R³   R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_intermingling`  s0       l   
   l   c         C€  sc  d „  } t  j j j | d d d ƒ\ } } } d } | | k } | sÝ t j d | f d | | f ƒ i d t j ƒ  k sŠ t j | ƒ r™ t j	 | ƒ n d d	 6t j	 | ƒ d
 6} d i | d 6} t
 t j | ƒ ƒ ‚ n  d  } } | j } d }	 | |	 ƒ }
 |
 s•d d i d t j ƒ  k s3t j | ƒ rBt j	 | ƒ n d d	 6t j	 | ƒ d 6t j	 |	 ƒ d 6t j	 |
 ƒ d 6} t
 t j | ƒ ƒ ‚ n  d  } }	 }
 | j } d }	 | |	 ƒ }
 |
 sQd d i d t j ƒ  k sït j | ƒ rþt j	 | ƒ n d d	 6t j	 | ƒ d 6t j	 |	 ƒ d 6t j	 |
 ƒ d 6} t
 t j | ƒ ƒ ‚ n  d  } }	 }
 d  S(   Nc         S€  s%   |  GHt  j j j j t | ƒ ƒ d S(   Ni*   (   R"   t   stdR/   R˜   R   R
   (   R…   t   y(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR   o  s    i   Rê   i   i*   s   ==s   %(py0)s == %(py3)st   resR   R    R   s   assert %(py5)sR!   Rš   sL   assert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.startswith
}(%(py4)s)
}Rƒ   R   R	   R7   t   4R³   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R"   R#   Rà   t   callR   R&   R   R   R   R   R   R   R   t
   startswith(   R(   R   Rë   Rƒ   R³   R*   R+   R,   R-   R   R:   R;   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_callcapturen  s.    	'   l   
	    u  	    u  c         C€  s   d „  } t  | ƒ d  S(   Nc          S€  s4   x- t  d ƒ D] }  t j j ƒ  } | j ƒ  q Wd  S(   Ni
   (   RZ   R"   R#   Rà   R´   (   R^   RŽ   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR)   z  s    (   R‡   (   R(   t   capfdR)   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt	   test_manyy  s    	(   R5   R6   R¨   R©   R­   Rè   Rï   Rñ   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyRß   Z  s
   			t   TestStdCaptureFDNotNowc           B€  s   e  Z e Z d  „  Z RS(   c         K€  s*   t  | d <t j j |   } | j ƒ  | S(   NR‰   (   R‹   R"   R#   Rà   RÞ   (   R(   R¬   RŽ   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR­   ƒ  s    

(   R5   R6   R¨   R©   R­   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyRò   €  s   c         C€  s1  t  j j d |  ƒ } t j d d j d ƒ ƒ t j d d j d ƒ ƒ | j ƒ  \ } } | |  k } | s't j d | f d | |  f ƒ i d	 t	 j
 ƒ  k s­ t j | ƒ r¼ t j | ƒ n d	 d
 6d t	 j
 ƒ  k sä t j |  ƒ ró t j |  ƒ n d d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } d  S(   NRƒ   i   R   t   asciii   R®   s   ==s   %(py0)s == %(py2)st   outfR   RQ   R   R   s   assert %(py4)sR	   (   s   ==(   s   %(py0)s == %(py2)ss   assert %(py4)s(   R"   R#   Rà   R   R   R   RŒ   R   R&   R   R   R   R   R   R   R   (   RQ   Rð   Rô   t   errfR+   R_   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_stdcapture_fd_tmpfile‰  s      “   t   TestStdCaptureFDinvalidFDc           B€  s   e  Z e Z d  „  Z RS(   c         C€  s˜  | j  d ƒ | j d ƒ } | j } d } | | k } | sâ t j d | f d | | f ƒ i d t j ƒ  k s t j | ƒ rŽ t j | ƒ n d d 6t j | ƒ d 6t j | ƒ d	 6} d i | d 6} t	 t j
 | ƒ ƒ ‚ n  d  } } } | j ƒ  d } d } | | k }	 |	 s†t j d |	 f d | | f ƒ i t j | ƒ d 6t j | ƒ d 6}
 d i |
 d 6} t	 t j
 | ƒ ƒ ‚ n  d  } }	 } d  S(   Nsÿ  
            import py, os
            def test_stdout():
                os.close(1)
                cap = py.io.StdCaptureFD(out=True, err=False, in_=False)
                cap.done()
            def test_stderr():
                os.close(2)
                cap = py.io.StdCaptureFD(out=False, err=True, in_=False)
                cap.done()
            def test_stdin():
                os.close(0)
                cap = py.io.StdCaptureFD(out=False, err=False, in_=True)
                cap.done()
        s   --capture=fdi    s   ==s+   %(py2)s
{%(py2)s = %(py0)s.ret
} == %(py5)st   resultR   R   R!   R   s   assert %(py7)sRj   t   passedi   s   %(py1)s == %(py4)sR   R	   s   assert %(py6)sR7   (   s   ==(   s+   %(py2)s
{%(py2)s = %(py0)s.ret
} == %(py5)ss   assert %(py7)s(   s   ==(   s   %(py1)s == %(py4)ss   assert %(py6)s(   RJ   t	   runpytestt   retR   R&   R   R   R   R   R   R   R   t   parseoutcomes(   R(   RH   Rø   R+   R¦   R   R-   R†   Rd   R*   R   R;   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_stdcapture_fd_invalid_fd“  s&    	    |       E   (   R5   R6   R¨   R©   Rý   (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR÷   ‘  s   c          C€  s7   t  j j d t ƒ }  |  j ƒ  |  j ƒ  |  j ƒ  d  S(   NR‰   (   R"   R#   R«   R‹   RŒ   R´   (   t   capsys(    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt"   test_capture_not_started_but_reset§  s    

c          C€  sô  t  j j ƒ  }  zÓt  j j d t ƒ } t j j d ƒ t j j d ƒ t	 d d ƒ t	 d d ƒ | j
 ƒ  \ } } d } | | k } | s t j d | f d | | f ƒ i d
 t j ƒ  k sÍ t j | ƒ rÜ t j | ƒ n d
 d 6t j | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } d } | | k } | s×t j d | f d | | f ƒ i d t j ƒ  k s„t j | ƒ r“t j | ƒ n d d 6t j | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } Wd  |  j
 ƒ  Xd  S(   NR—   R   R®   i   Rá   i   t   2s   ==s   %(py0)s == %(py3)sRƒ   R   R    R   s   assert %(py5)sR!   R³   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R"   R#   R«   Rà   R‹   R/   R¯   R   R˜   R   R´   R   R&   R   R   R   R   R   R   R   (   Rþ   RŽ   Rƒ   R³   R*   R+   R,   R-   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_capture_no_sys­  s.       l   
   l   c          C€  sŠ  d „  }  t  j j d t ƒ } z+ t  j j j |  d d d ƒ\ } } } Wd  | j ƒ  Xd } | | k } | st j d | f d | | f ƒ i d	 t	 j
 ƒ  k s± t j | ƒ rÀ t j | ƒ n d	 d
 6t j | ƒ d 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } | j } d }	 | |	 ƒ }
 |
 s¼d d i d t	 j
 ƒ  k sZt j | ƒ rit j | ƒ n d d
 6t j | ƒ d 6t j |	 ƒ d 6t j |
 ƒ d 6} t t j | ƒ ƒ ‚ n  d  } }	 }
 | j } d }	 | |	 ƒ }
 |
 sxd d i d t	 j
 ƒ  k st j | ƒ r%t j | ƒ n d d
 6t j | ƒ d 6t j |	 ƒ d 6t j |
 ƒ d 6} t t j | ƒ ƒ ‚ n  d  } }	 }
 d  S(   Nc         S€  s9   t  d d ƒ t  d d ƒ |  GHt j j t | ƒ ƒ d S(   Ni   R   i   i*   (   R   R/   R˜   R   R
   (   R…   Rê   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyR   ¾  s
    R—   i   Rê   i   i*   s   ==s   %(py0)s == %(py3)sRë   R   R    R   s   assert %(py5)sR!   Rš   sL   assert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.startswith
}(%(py4)s)
}Rƒ   R   R	   R7   Rì   R³   (   s   ==(   s   %(py0)s == %(py3)ss   assert %(py5)s(   R"   R#   Rà   R‹   R«   Rí   R´   R   R&   R   R   R   R   R   R   R   Rî   (   R   Rð   Rë   Rƒ   R³   R*   R+   R,   R-   R   R:   R;   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   test_callcapture_nofd¼  s4    	+   l   
	    u  	    u  t   usec         C€  s>  | s t  }  n  t j j d t d |  d t ƒ } | j ƒ  | j j } | j ƒ  | j	 ƒ  | j j } | | k } | s4t
 j d | f d | | f ƒ i d t j ƒ  k sº t
 j | ƒ rÉ t
 j | ƒ n d d 6d t j ƒ  k sñ t
 j | ƒ r t
 j | ƒ n d d	 6} d i | d 6} t t
 j | ƒ ƒ ‚ n  d  } d  S(   NRƒ   R³   R‰   s   ==s   %(py0)s == %(py2)st   capfile2R   t   capfileR   R   s   assert %(py4)sR	   (   s   ==(   s   %(py0)s == %(py2)ss   assert %(py4)s(   Ro   R"   R#   Rà   R‹   RÞ   R³   RQ   RØ   RÙ   R   R&   R   R   R   R   R   R   R   (   RQ   R  RŽ   R  R  R+   R_   R   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt'   test_fdcapture_tmpfile_remains_the_sameÎ  s    	!


  “   t   methodR«   Rà   c         C€  s|  | d k r/ t  t d ƒ r/ t j j d ƒ n  |  j d | f ƒ } |  j | ƒ } | j j d d g ƒ d } | j	 } | j
 } | ƒ  } | | k } | sbt j d | f d | | f ƒ i t j | ƒ d
 6t j | ƒ d 6d t j ƒ  k sÿ t j | ƒ rt j | ƒ n d d 6t j | ƒ d 6t j | ƒ d 6}	 d i |	 d 6}
 t t j |
 ƒ ƒ ‚ n  d  } } } } } d  S(   NRà   t   dups   need os.dups  
        import sys, os
        import py, logging
        cap = py.io.%s(out=False, in_=False)

        logging.warn("hello1")
        outerr = cap.suspend()
        print ("suspend, captured %%s" %%(outerr,))
        logging.warn("hello2")

        cap.resume()
        logging.warn("hello3")

        outerr = cap.suspend()
        print ("suspend2, captured %%s" %% (outerr,))
    s   suspend, captured*hello1*s.   suspend2, captured*hello2*WARNING:root:hello3*t   atexits   not insb   %(py1)s not in %(py9)s
{%(py9)s = %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.stderr
}.str
}()
}Ri   R   Rø   R    R!   Rj   R   s   assert %(py11)sRk   (   s   not in(   sb   %(py1)s not in %(py9)s
{%(py9)s = %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.stderr
}.str
}()
}s   assert %(py11)s(   t   hasattrR   R"   R1   R}   RJ   t	   runpythonR¯   t   fnmatch_linesR˜   R
   R   R&   R   R   R   R   R   R   R   (   RH   R  t   pRø   Rd   R¦   Rp   Rq   R*   Rr   Rs   (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt'   test_capturing_and_logging_fundamentalsÛ  s$    	
 	 	 	   œ   (   i   i    (    (    (    (    (+   t
   __future__R    t   __builtin__R   t   _pytest.assertion.rewritet	   assertiont   rewriteR   R   R/   R"   R1   RÛ   RÜ   R¨   t
   py.builtinR   R0   R   R   R   R   R=   RG   RN   Re   Rt   R‡   Rˆ   Rª   RÝ   Rß   Rò   Rö   R÷   Rÿ   R  R  t   multiRo   R‹   R  R  (    (    (    s>   /home/ronny/Projects/pytest-dev/py/testing/io_/test_capture.pyt   <module>   s@     						
			J&		*