
:îÜWç  ã               @   sK  d  d l  Z d  d l j j Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 e j
 j j d ƒ Z d d „  Z d d „  Z d d „  Z d	 d
 „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d d  „  Z d! d" „  Z d# d$ „  Z d% d& „  Z d' d( „  Z  d S))é    Nznot hasattr(os, 'fork')c           
   C   s•  t  j j t ƒ }  |  j } | j } | ƒ  } | s¹ d d d t j | ƒ d t j | ƒ d d t j	 ƒ  k s| t j
 |  ƒ r‹ t j |  ƒ n d d t j | ƒ i } t t j | ƒ ƒ ‚ d  } } } |  j ƒ  |  j } | j } | ƒ  } | } | sd d d t j | ƒ d t j | ƒ d d t j	 ƒ  k sBt j
 |  ƒ rQt j |  ƒ n d d t j | ƒ i } t t j | ƒ ƒ ‚ d  } } } } d  S)	NÚ z]assert %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.tempdir
}.check
}()
}Úpy4Úpy6Úpy0ÚffÚpy2zaassert not %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.tempdir
}.check
}()
})ÚpyÚprocessÚ
ForkedFuncÚboxf1ÚtempdirÚcheckÚ
@pytest_arÚ	_safereprÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚAssertionErrorÚ_format_explanationÚ
waitfinish)r   Ú@py_assert1Ú@py_assert3Ú@py_assert5Ú@py_format7Ú@py_assert7Ú@py_format8© r   úE/home/ronny/Projects/pytest-dev/py/testing/process/test_forkedfunc.pyÚtest_waitfinish_removes_tempdir   s"    	 	 	  q  
	 	 	   q  r   c          
   C   s®  |  j  t d d d „  ƒ t j j t ƒ } | j } | j } | ƒ  } | sÒ d d d t j	 | ƒ d t j	 | ƒ d d	 t
 j ƒ  k s• t j | ƒ r¤ t j	 | ƒ n d	 d
 t j	 | ƒ i } t t j | ƒ ƒ ‚ d  } } } | j ƒ  | j } | j } | ƒ  } | } | s˜d d d t j	 | ƒ d t j	 | ƒ d d	 t
 j ƒ  k s[t j | ƒ rjt j	 | ƒ n d	 d
 t j	 | ƒ i } t t j | ƒ ƒ ‚ d  } } } } d  S)NÚforkc               S   s
   t  j ƒ  S)N)ÚosÚgetpidr   r   r   r   Ú<lambda>   s    z0test_tempdir_gets_gc_collected.<locals>.<lambda>r   z]assert %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.tempdir
}.check
}()
}r   r   r   r   r   zaassert not %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.tempdir
}.check
}()
})Úsetattrr    r   r	   r
   r   r   r   r   r   r   r   r   r   r   Ú__del__)Úmonkeypatchr   r   r   r   r   r   r   r   r   r   Útest_tempdir_gets_gc_collected   s$    	 	 	  q  
	 	 	   q  r&   c              C   s  t  j j t ƒ j ƒ  }  |  j } d } | | k } | s× t j d | f d | | f ƒ d d t j	 ƒ  k s{ t j
 |  ƒ rŠ t j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | s¤t j d | f d | | f ƒ d d t j	 ƒ  k sHt j
 |  ƒ rWt j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | sqt j d | f d | | f ƒ d d t j	 ƒ  k st j
 |  ƒ r$t j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | s>t j d | f d | | f ƒ d d t j	 ƒ  k sât j
 |  ƒ rñt j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | st j d | f d | | f ƒ d d t j	 ƒ  k s¯t j
 |  ƒ r¾t j |  ƒ n d d t j | ƒ d t j | ƒ i } d  d
 | i } t t j | ƒ ƒ ‚ d  } } } d  S)!Nz	some out
ú==ú+%(py2)s
{%(py2)s = %(py0)s.out
} == %(py5)sr   Úresultr   Úpy5r   úassert %(py7)sÚpy7z	some err
ú+%(py2)s
{%(py2)s = %(py0)s.err
} == %(py5)sr   ú2%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py5)sú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sé   ú.%(py2)s
{%(py2)s = %(py0)s.retval
} == %(py5)s)r'   )r(   r+   )r'   )r-   r+   )r'   )r.   r+   )r'   )r/   r+   )r'   )r1   r+   )r   r	   r
   r   r   Úoutr   Ú_call_reprcomparer   r   r   r   r   r   ÚerrÚ
exitstatusÚsignalÚretval)r)   r   Ú@py_assert4r   Ú@py_format6r   r   r   r   Útest_basic_forkedfunc   sR    	    y   	    y   	    y   	    y   	    y   r:   c              C   sÒ  d d „  }  t  j j |  ƒ j ƒ  } | j } d } | | k } | sã t j d | f d | | f ƒ d d t j ƒ  k s‡ t j	 | ƒ r– t j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } d } | | k } | s°t j d | f d | | f ƒ d d t j ƒ  k sTt j	 | ƒ rct j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } | } | s<d
 d d d t j ƒ  k sÿt j	 | ƒ rt j
 | ƒ n d d t j
 | ƒ i } t t j | ƒ ƒ ‚ d  } } | j } | } | sÄd
 d d d t j ƒ  k s‡t j	 | ƒ r–t j
 | ƒ n d d t j
 | ƒ i } t t j | ƒ ƒ ‚ d  } } d  S)Nc               S   s   t  j d ƒ d  S)Né   )r    Ú_exitr   r   r   r   Úfunc   s    ztest_exitstatus.<locals>.funcr;   r'   ú2%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   r   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sz+assert not %(py2)s
{%(py2)s = %(py0)s.out
}z+assert not %(py2)s
{%(py2)s = %(py0)s.err
})r'   )r>   r?   )r'   )r@   r?   )r   r	   r
   r   r5   r   r3   r   r   r   r   r   r   r6   r2   r4   )r=   r)   r   r8   r   r9   r   Ú@py_format4r   r   r   Útest_exitstatus   s<    	    y   	    y   	   S  
	   S  rB   c              C   sµ  d d „  }  t  j j |  ƒ } | j ƒ  } | j } | j } | | k } | s"t j d | f d | | f ƒ d d t j	 ƒ  k s t j
 | ƒ rŸ t j | ƒ n d d t j | ƒ d d	 t j	 ƒ  k sÕ t j
 | ƒ rä t j | ƒ n d	 d
 t j | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } | j } d } | | ƒ } d }	 |	 }
 | |
 k } | s>t j d | f d | |
 f ƒ d t j | ƒ d d	 t j	 ƒ  k sÄt j
 | ƒ rÓt j | ƒ n d	 d t j | ƒ d t j | ƒ d t j |	 ƒ d
 t j | ƒ i } d  d | i } t t j | ƒ ƒ ‚ d  } } } } } }	 }
 | j } d } | | k } | st j d! | f d" | | f ƒ d d	 t j	 ƒ  k s¿t j
 | ƒ rÎt j | ƒ n d	 d
 t j | ƒ d t j | ƒ i } d# d | i } t t j | ƒ ƒ ‚ d  } } } | j } | } | s§d d d d	 t j	 ƒ  k sjt j
 | ƒ ryt j | ƒ n d	 d
 t j | ƒ i } t t j | ƒ ƒ ‚ d  } } d  S)$Nc               S   s   t  d ƒ ‚ d  S)Né*   )Ú
ValueErrorr   r   r   r   Úfun&   s    z#test_execption_in_func.<locals>.funr'   ú\%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py6)s
{%(py6)s = %(py4)s.EXITSTATUS_EXCEPTION
}r   r   r   r   r)   r   r   úassert %(py8)sÚpy8zValueError: 42r0   ú!=úe%(py8)s
{%(py8)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.err
}.find
}(%(py6)s)
} != -%(py11)sÚpy11úassert %(py14)sÚpy14r   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sr*   úassert %(py7)sr,   z.assert not %(py2)s
{%(py2)s = %(py0)s.retval
})r'   )rF   rG   )rI   )rJ   rL   )r'   )rN   rO   )r   r	   r
   r   r5   ZEXITSTATUS_EXCEPTIONr   r3   r   r   r   r   r   r   r4   Úfindr6   r7   )rE   r   r)   r   r   r   r   Ú@py_format9r   Ú@py_assert10Ú@py_assert12Ú@py_assert9Ú@py_format13Ú@py_format15r8   r9   r   rA   r   r   r   Útest_execption_in_func%   sJ    	 	   ¯   	 	       ¦   	    y   	   S  rW   c              C   s  t  j j t ƒ j ƒ  }  |  j } d } | | k } | s× t j d | f d | | f ƒ d d t j	 ƒ  k s{ t j
 |  ƒ rŠ t j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | s¤t j d | f d | | f ƒ d d t j	 ƒ  k sHt j
 |  ƒ rWt j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | sqt j d | f d | | f ƒ d d t j	 ƒ  k st j
 |  ƒ r$t j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | s>t j d | f d | | f ƒ d d t j	 ƒ  k sât j
 |  ƒ rñt j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | st j d | f d | | f ƒ d d t j	 ƒ  k s¯t j
 |  ƒ r¾t j |  ƒ n d d t j | ƒ d t j | ƒ i } d  d
 | i } t t j | ƒ ƒ ‚ d  } } } d  S)!NÚsomeoutr'   ú+%(py2)s
{%(py2)s = %(py0)s.out
} == %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   Úsomeerrú+%(py2)s
{%(py2)s = %(py0)s.err
} == %(py5)sr   ú2%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py5)sú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sé   ú.%(py2)s
{%(py2)s = %(py0)s.retval
} == %(py5)s)r'   )rY   rZ   )r'   )r\   rZ   )r'   )r]   rZ   )r'   )r^   rZ   )r'   )r`   rZ   )r   r	   r
   Úboxf2r   r2   r   r3   r   r   r   r   r   r   r4   r5   r6   r7   )r)   r   r8   r   r9   r   r   r   r   Útest_forkedfunc_on_fds/   sR    	    y   	    y   	    y   	    y   	    y   rb   c              C   s¶  t  j j t ƒ j ƒ  }  |  j } d } | | k } | s× t j d | f d | | f ƒ d d t j	 ƒ  k s{ t j
 |  ƒ rŠ t j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | s¤t j d | f d | | f ƒ d d t j	 ƒ  k sHt j
 |  ƒ rWt j |  ƒ n d d t j | ƒ d t j | ƒ i } d d
 | i } t t j | ƒ ƒ ‚ d  } } } d  S)Né   r'   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   Úsú+%(py2)s
{%(py2)s = %(py0)s.out
} == %(py5)s)r'   )rd   re   )r'   )rg   re   )r   r	   r
   Úboxf3r   r6   r   r3   r   r   r   r   r   r   r2   )r)   r   r8   r   r9   r   r   r   r   Útest_forkedfunc_on_fds_output7   s"    	    y   	    y   ri   c              C   sÂ  d d „  }  t  j j |  ƒ j ƒ  } | j } d } | | k } | sã t j d | f d | | f ƒ d d t j ƒ  k s‡ t j	 | ƒ r– t j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } d } | | k } | s°t j d | f d | | f ƒ d d t j ƒ  k sTt j	 | ƒ rct j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } d  S)Nc              S   s6   d d  l  }  |  j j d ƒ t j t j ƒ  d ƒ d  S)Nr   zhello
rc   )ÚsysÚstdoutÚwriter    Úkillr!   )rj   r   r   r   rh   >   s    z(test_forkedfunc_on_stdout.<locals>.boxf3rc   r'   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   zhello
ú+%(py2)s
{%(py2)s = %(py0)s.out
} == %(py5)s)r'   )rn   ro   )r'   )rp   ro   )r   r	   r
   r   r6   r   r3   r   r   r   r   r   r   r2   )rh   r)   r   r8   r   r9   r   r   r   r   Útest_forkedfunc_on_stdout=   s$    	    y   	    y   rq   c              C   sÕ  t  j j t ƒ j ƒ  }  |  j } d  } | | k } | s× t j d | f d | | f ƒ d d t j	 ƒ  k s{ t j
 |  ƒ rŠ t j |  ƒ n d d t j | ƒ d t j | ƒ i } d d	 | i } t t j | ƒ ƒ ‚ d  } } } t j d k  rt  j j d ƒ |  j } d } | | k } | sÃt j d | f d | | f ƒ d d t j	 ƒ  k sgt j
 |  ƒ rvt j |  ƒ n d d t j | ƒ d t j | ƒ i } d d	 | i } t t j | ƒ ƒ ‚ d  } } } d  S)NÚisú.%(py2)s
{%(py2)s = %(py0)s.retval
} is %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   r_   r;   z4signal detection does not work with python prior 2.4rc   r'   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)s)rr   )rs   rt   )r_   r;   )r'   )ru   rt   )r   r	   r
   Úboxsegr   r7   r   r3   r   r   r   r   r   r   rj   Úversion_infoÚtestÚskipr6   )r)   r   r8   r   r9   r   r   r   r   Útest_forkedfunc_signalF   s&    	    y   	    y   rz   c              C   s   t  j j t ƒ j ƒ  }  |  j } | s d d d d t j ƒ  k sR t j	 |  ƒ ra t j
 |  ƒ n d d t j
 | ƒ i } t t j | ƒ ƒ ‚ d  } |  j } d } | | k } | sTt j d | f d | | f ƒ d d t j ƒ  k sø t j	 |  ƒ rt j
 |  ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | s!t j d | f d | | f ƒ d d t j ƒ  k sÅt j	 |  ƒ rÔt j
 |  ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } |  j } d } | | k } | sît j d | f d | | f ƒ d d t j ƒ  k s’t j	 |  ƒ r¡t j
 |  ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } d  S)Nr   z'assert %(py2)s
{%(py2)s = %(py0)s.out
}r   r)   r   r   r'   ú2%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py5)sr*   úassert %(py7)sr,   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sé   ú.%(py2)s
{%(py2)s = %(py0)s.retval
} == %(py5)s)r'   )r{   r|   )r'   )r}   r|   )r'   )r   r|   )r   r	   r
   Úboxhuger   r2   r   r   r   r   r   r   r   r5   r3   r6   r7   )r)   r   Ú@py_format3r8   r   r9   r   r   r   r   Útest_forkedfunc_huge_dataM   s<    	  S  	    y   	    y   	    y   r‚   c           	   C   s  xt  d ƒ D]}  t j j t ƒ j ƒ  } | j } | s¢ d d d d t j ƒ  k se t	 j
 | ƒ rt t	 j | ƒ n d d t	 j | ƒ i } t t	 j | ƒ ƒ ‚ d  } | j } d } | | k } | sgt	 j d | f d | | f ƒ d d t j ƒ  k st	 j
 | ƒ rt	 j | ƒ n d d t	 j | ƒ d
 t	 j | ƒ i } d d | i } t t	 j | ƒ ƒ ‚ d  } } } | j } d } | | k } | s4t	 j d | f d | | f ƒ d d t j ƒ  k sØt	 j
 | ƒ rçt	 j | ƒ n d d t	 j | ƒ d
 t	 j | ƒ i } d d | i } t t	 j | ƒ ƒ ‚ d  } } } | j } d } | | k } | st	 j d | f d | | f ƒ d d t j ƒ  k s¥t	 j
 | ƒ r´t	 j | ƒ n d d t	 j | ƒ d
 t	 j | ƒ i } d d | i } t t	 j | ƒ ƒ ‚ d  } } } q Wd  S)Né2   r   z'assert %(py2)s
{%(py2)s = %(py0)s.out
}r   r)   r   r   r'   ú2%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py5)sr*   úassert %(py7)sr,   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sr~   ú.%(py2)s
{%(py2)s = %(py0)s.retval
} == %(py5)s)r'   )r„   r…   )r'   )r†   r…   )r'   )r‡   r…   )Úranger   r	   r
   r€   r   r2   r   r   r   r   r   r   r   r5   r3   r6   r7   )Úir)   r   r   r8   r   r9   r   r   r   r   Útest_box_seqT   s>    	  S  	    y   	    y   	    y   rŠ   c              C   s)  d d „  }  t  j j |  ƒ j ƒ  } | j } d } | | k } | sã t j d | f d | | f ƒ d d t j ƒ  k s‡ t j	 | ƒ r– t j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } d } | | k } | s°t j d | f d | | f ƒ d d t j ƒ  k sTt j	 | ƒ rct j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } d } | | k } | s}t j d | f d | | f ƒ d d t j ƒ  k s!t j	 | ƒ r0t j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } d } | | k } | sJt j d | f d | | f ƒ d d t j ƒ  k sît j	 | ƒ rýt j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d d | i } t t j | ƒ ƒ ‚ d  } } } | j } d } | | k } | st j d  | f d! | | f ƒ d d t j ƒ  k s»t j	 | ƒ rÊt j
 | ƒ n d d t j
 | ƒ d	 t j
 | ƒ i } d" d | i } t t j | ƒ ƒ ‚ d  } } } d  S)#Nc              S   sC   t  j j t ƒ j ƒ  }  t |  j ƒ t j j	 |  j
 d ƒ |  j S)NÚ
)r   r	   r
   ra   r   Úprintr2   rj   Ústderrrl   r4   r7   )r)   r   r   r   Úboxfun^   s    z!test_box_in_a_box.<locals>.boxfunzsomeout
r'   ú+%(py2)s
{%(py2)s = %(py0)s.out
} == %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   zsomeerr
ú+%(py2)s
{%(py2)s = %(py0)s.err
} == %(py5)sr   ú2%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py5)sú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sr_   ú.%(py2)s
{%(py2)s = %(py0)s.retval
} == %(py5)s)r'   )r   r   )r'   )r‘   r   )r'   )r’   r   )r'   )r“   r   )r'   )r”   r   )r   r	   r
   r   r2   r   r3   r   r   r   r   r   r   r4   r5   r6   r7   )rŽ   r)   r   r8   r   r9   r   r   r   r   Útest_box_in_a_box]   sT    	    y   	    y   	    y   	    y   	    y   r•   c        
         sa  Gd d „  d ƒ }  |  ƒ  } d d  l  ‰  ‡  f d d †  } t j j | ƒ } t j | j d ƒ | j ƒ  } t j j	 j
 d k  r t j j d	 ƒ | j } d } | | k } | sOt j d | f d | | f ƒ d d t j ƒ  k só t j | ƒ rt j | ƒ n d d t j | ƒ d t j | ƒ i } d d | i }	 t t j |	 ƒ ƒ ‚ d  } } } d  S)Nc               @   s   e  Z d  Z d S)z test_kill_func_forked.<locals>.AN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   ÚAl   s   r™   r   c                  s   ˆ  j  d ƒ d  S)Né
   )Úsleepr   )Útimer   r   Úbox_funq   s    z&test_kill_func_forked.<locals>.box_funé   r_   r;   z4signal detection does not work with python prior 2.4r'   ú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   )r_   r;   )r'   )rŸ   r    )rœ   r   r	   r
   r    rm   Úpidr   Ústdrj   rw   rx   ry   r6   r   r3   r   r   r   r   r   r   )
r™   Úinfor   r   r)   r   r8   r   r9   r   r   )rœ   r   Útest_kill_func_forkedk   s"    		    y   r¤   c       
      C   sM  d d „  } d d „  } d d „  } t  j j | d | d | ƒj ƒ  } | j } d	 } | | k } | st j d | f d | | f ƒ d d t j ƒ  k s« t j	 | ƒ rº t j
 | ƒ n d d t j
 | ƒ d t j
 | ƒ i } d d | i }	 t t j |	 ƒ ƒ ‚ d  } } } | j } d } | | k } | sÔt j d | f d | | f ƒ d d t j ƒ  k sxt j	 | ƒ r‡t j
 | ƒ n d d t j
 | ƒ d t j
 | ƒ i } d d | i }	 t t j |	 ƒ ƒ ‚ d  } } } | j } d } | | k } | s¡t j d  | f d! | | f ƒ d d t j ƒ  k sEt j	 | ƒ rTt j
 | ƒ n d d t j
 | ƒ d t j
 | ƒ i } d" d | i }	 t t j |	 ƒ ƒ ‚ d  } } } | j } d } | | k } | snt j d# | f d$ | | f ƒ d d t j ƒ  k st j	 | ƒ r!t j
 | ƒ n d d t j
 | ƒ d t j
 | ƒ i } d% d | i }	 t t j |	 ƒ ƒ ‚ d  } } } | j } d } | | k } | s;t j d& | f d' | | f ƒ d d t j ƒ  k sßt j	 | ƒ rît j
 | ƒ n d d t j
 | ƒ d t j
 | ƒ i } d( d | i }	 t t j |	 ƒ ƒ ‚ d  } } } d  S))Nc               S   s   d S)Nr0   r   r   r   r   r   Ú_boxed}   s    ztest_hooks.<locals>._boxedc               S   s!   t  j j d ƒ t  j j ƒ  d  S)Nz	some out
)rj   rk   rl   Úflushr   r   r   r   Ú	_on_start€   s    ztest_hooks.<locals>._on_startc               S   s!   t  j j d ƒ t  j j ƒ  d  S)Nz	some err
)rj   r   rl   r¦   r   r   r   r   Ú_on_exit„   s    ztest_hooks.<locals>._on_exitZchild_on_startZchild_on_exitz	some out
r'   ú+%(py2)s
{%(py2)s = %(py0)s.out
} == %(py5)sr   r)   r   r*   r   úassert %(py7)sr,   z	some err
ú+%(py2)s
{%(py2)s = %(py0)s.err
} == %(py5)sr   ú2%(py2)s
{%(py2)s = %(py0)s.exitstatus
} == %(py5)sú.%(py2)s
{%(py2)s = %(py0)s.signal
} == %(py5)sr0   ú.%(py2)s
{%(py2)s = %(py0)s.retval
} == %(py5)s)r'   )r©   rª   )r'   )r«   rª   )r'   )r¬   rª   )r'   )r­   rª   )r'   )r®   rª   )r   r	   r
   r   r2   r   r3   r   r   r   r   r   r   r4   r5   r6   r7   )
r%   r¥   r§   r¨   r)   r   r8   r   r9   r   r   r   r   Ú
test_hooks|   sZ    	    y   	    y   	    y   	    y   	    y   r¯   c               C   s$   t  j j d ƒ t  j j d ƒ d S)Nz	some out
z	some err
r0   )rj   rk   rl   r   r   r   r   r   r   –   s    r   c               C   s6   t  j d d j d ƒ ƒ t  j d d j d ƒ ƒ d S)Nr0   rX   Úasciir_   r[   )r    rl   Úencoder   r   r   r   ra   ›   s    ra   c               C   s3   t  j d d j d ƒ ƒ t  j t  j ƒ  d ƒ d  S)Nr0   rf   r°   rc   )r    rl   r±   rm   r!   r   r   r   r   rh       s    rh   c               C   s   t  j t  j ƒ  d ƒ d  S)Nrc   )r    rm   r!   r   r   r   r   rv   ¤   s    rv   c              C   sŸ   d j  d ƒ }  t j d |  d ƒ t j d |  d ƒ t j d |  d ƒ t j d |  d ƒ t j d |  d ƒ t j d |  d ƒ t j d |  d ƒ d S)Nú r°   r0   i'  r_   r~   )r±   r    rl   )rf   r   r   r   r€   §   s    r€   )!Úbuiltinsr   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter   Úpytestr   rj   r    rx   ÚmarkÚskipifÚ
pytestmarkr   r&   r:   rB   rW   rb   ri   rq   rz   r‚   rŠ   r•   r¤   r¯   r   ra   rh   rv   r€   r   r   r   r   Ú<module>   s.     $	
		