
3W{                 @   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
 d  d l Z d  d l Z d  d l m Z d  d l Z e	 j j j d  Z e	 j j j d  Z e	 j j j d  Z e	 j j j d  Z d Z d	 d
   Z d d   Z Gd d   d e j  Z Gd d   d  Z Gd d   d  Z Gd 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' Gd% d&   d&  Z( Gd' d(   d(  Z) Gd) d*   d*  Z* Gd+ d,   d,  Z+ d S)-    )with_statementN)localzsys.platform.startswith('java')zFsys.platform.startswith('java') and getattr(os, '_name', None) == 'nt'zCnot (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')z=sys.platform == 'win32' or getattr(os, '_name', None) == 'nt'g{Gz?c                s4     f d d   } d d   }   j  | | d d S)Nc                 s      j  d  }  t j |   |  S)Ntmpdir)getfuncargvaluecommonZsetuptestfs)path1)request =/home/ronny/Projects/pytest-dev/py/testing/path/test_local.pysetup   s    z$pytest_funcarg__path1.<locals>.setupc             S   s   |  j  } d } | |  } | j } |   } | s d d d t j |  d t j |  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  } } } } } d  S)N
samplefile zzassert %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py4)s)
}.check
}()
}py4py10py8py6py0r   py2)	joincheck
@pytest_ar	_saferepr@py_builtinslocals_should_repr_global_nameAssertionError_format_explanation)r   @py_assert1@py_assert3@py_assert5@py_assert7@py_assert9@py_format11r	   r	   r
   teardown   s    	   	 	    z'pytest_funcarg__path1.<locals>.teardownscopesession)cached_setup)r   r   r#   r	   )r   r
   pytest_funcarg__path1   s    r'   c             C   s    Gd d   d t   } | d  S)Nc               @   s(   e  Z d  Z d d   Z d d   Z d S)z8pytest_funcarg__fake_fspath_obj.<locals>.FakeFSPathClassc             S   s   | |  _  d  S)N)_path)selfpathr	   r	   r
   __init__"   s    zApytest_funcarg__fake_fspath_obj.<locals>.FakeFSPathClass.__init__c             S   s   |  j  S)N)r(   )r)   r	   r	   r
   
__fspath__$   s    zCpytest_funcarg__fake_fspath_obj.<locals>.FakeFSPathClass.__fspath__N)__name__
__module____qualname__r+   r,   r	   r	   r	   r
   FakeFSPathClass!   s   r0   zthis/is/a/fake/path)object)r   r0   r	   r	   r
   pytest_funcarg__fake_fspath_obj    s    r2   c               @   s  e  Z d  Z d d   Z e d d    Z d d   Z d d   Z d	 d
   Z d d   Z	 d d   Z
 d d   Z e d d    Z d d   Z d d   Z d d   Z e j j d  d d    Z d d   Z d d   Z d  d!   Z d" d#   Z d$ d%   Z e j j j d& dM  d) d*    Z e d+ d,    Z d- d.   Z d/ d0   Z  d1 d2   Z! d3 d4   Z" d5 d6   Z# d7 d8   Z$ d9 d:   Z% d; d<   Z& e j j j d= d' d> d?  d@ dA    Z' dB dC   Z( dD dE   Z) dF dG   Z* dH dI   Z+ dJ dK   Z, dL S)NTestLocalPathc             C   s  | j  } d } | |  } | | k } | st j d | f d | | f  d t j |  d t j |  d d t j   k s t j |  r t j |  n d 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  d | j	  } | | k } | s t j d | f d | | f  d d t j   k st j |  rt j |  n d d	 d t j   k st j |  rt j |  n d i }	 d d |	 i }
 t t j |
    d  } | j  d | j	  } | | k } | st j d | f d | | f  d d t j   k spt j |  rt j |  n d d	 d t j   k st j |  rt j |  n d i }	 d d |	 i }
 t t j |
    d  } d  S)N.==J%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py4)s)
} == %(py8)sr   r   r   r   r   r   r   assert %(py10)sr   z../%s%(py0)s == %(py2)spassert %(py4)sz..//%s/)r5   )r6   r7   )r5   )r8   r:   )r5   )r8   r:   )
r   r   _call_reprcomparer   r   r   r   r   r   basename)r)   r   r   r   r   r    @py_format9r"   r9   @py_format3@py_format5r	   r	   r
   test_join_normpath)   s.    	                  z TestLocalPath.test_join_normpathc             C   sP  | j  d  } | j } d } | |  } | j  } d } | |  } | | k }	 |	 rrt j d f |	 f d f | | f  d t j |  d t j |  d t j |  d	 d
 t j   k p t j |  r t j |  n d
 d t j |  d t j |  d d t j   k pt j |  r0t j |  n d d t j |  i }
 d d d |
 i } t t j	 |    d  } } } }	 } } } | j } d } d } | | d | }	 t
 j } | j } d } | |  } |	 | k } | r&t j d f | f d f |	 | f  d t j |  d d t j   k pBt j t
  rTt j t
  n d d t j |  d t j |  d	 t j |	  d t j |  d t j |  d t j |  d d
 t j   k pt j |  rt j |  n d
 d t j |  i
 } d d d | i } t t j	 |    d  } } } }	 } } } } } d  S)Nfooz/barbarr5   z%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.dirpath
}(%(py4)s)
} == %(py14)s
{%(py14)s = %(py10)s
{%(py10)s = %(py8)s.join
}(%(py12)s)
}r   r   py12r   r   py14r   r   r9   r   r   zassert %(py16)spy16Tabsz%(py8)s
{%(py8)s = %(py2)s
{%(py2)s = %(py0)s.dirpath
}(%(py4)s, abs=%(py6)s)
} == %(py18)s
{%(py18)s = %(py14)s
{%(py14)s = %(py12)s
{%(py12)s = %(py10)s.path
}.local
}(%(py16)s)
}pypy18zassert %(py20)spy20)r   dirpathr   r;   r   r   r   r   r   r   rG   r*   r   )r)   r   r9   r   r   r   r!   @py_assert11@py_assert13r    @py_format15@py_format17@py_assert15@py_assert17@py_format19Z@py_format21r	   r	   r
   test_dirpath_abs_no_abs0   s8    	   	        	    	 	         z%TestLocalPath.test_dirpath_abs_no_absc             C   s  t  j j d d  j } t  j j d d  } t | d t | d d    } | j d  } d j d  } | j | d d	 | j } d } | |  }	 | |  }
 |
 j	 } |   } |	 | k } | rt
 j d
 f | f d f |	 | f  d t
 j |  d t
 j |
  d d t j   k p+t
 j |  r=t
 j |  n d d t
 j |  d t
 j |	  d d t j   k pt
 j |  rt
 j |  n d d d t j   k pt
 j |  rt
 j |  n d d t
 j |  d t
 j |  i	 } d d d | i } t t
 j |    d  } } }	 } }
 } } | j } d } | |  }	 | |  }
 |
 j	 } |   } |	 | k } | rt
 j d
 f | f d f |	 | f  d t
 j |  d t
 j |
  d d t j   k pt
 j |  rt
 j |  n d d t
 j |  d t
 j |	  d d t j   k p9t
 j |  rKt
 j |  n d d d t j   k pot
 j |  rt
 j |  n d d t
 j |  d t
 j |  i	 } d d d | i } t t
 j |    d  } } }	 } }
 } } t  j j t | j d  d  S)Nmd5hashlibshasha1Ztesthashfilehelloasciimodewbr5   z%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.computehash
}(%(py4)s)
} == %(py15)s
{%(py15)s = %(py13)s
{%(py13)s = %(py11)s
{%(py11)s = %(py8)s(%(py9)s)
}.hexdigest
}()
}r   py11r   py13r   py9datar   fnr   py15r   zassert %(py17)spy17Zasdasd)rG   builtin
_tryimportrS   getattrr   encodewritecomputehash	hexdigestr   r;   r   r   r   r   r   r   testraises
ValueError)r)   r   rS   librU   r_   r^   r   r   r   @py_assert10@py_assert12@py_assert14r    @py_format16@py_format18r	   r	   r
   test_gethash6   sB    	    	 	    (   	    	 	    (   zTestLocalPath.test_gethashc          
   C   s   | j  d  j   } | j d  | j   | j } d } | d |  } | } | 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  } } } } d  S)Nreadonlyr      existsr   zRassert not %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(exists=%(py4)s)
}r   r   r   readonly_filer   )r   ensurechmodremover   r   r   r   r   r   r   r   )r)   r   rv   r   r   r   r    @py_format8r	   r	   r
   !test_remove_removes_readonly_fileA   s    
	     q  z/TestLocalPath.test_remove_removes_readonly_filec          
   C   s  | j  d  j d d  } | j t d d   | j   | j } d } | d |  } | } | 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  } } } } d  S)Nreadonlydirdirrt   500   ru   r   zRassert not %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(exists=%(py4)s)
}r   r   r   readonly_dirr   )r   rw   rx   intry   r   r   r   r   r   r   r   r   )r)   r   r   r   r   r   r    rz   r	   r	   r
    test_remove_removes_readonly_dirG   s    
	     q  z.TestLocalPath.test_remove_removes_readonly_dirc       	   
   C   s  | j  d  j d d  } | j  d  j   } | j d  | j   | j } d } | d |  } | } | 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  } } } } d  S)Nr|   r}   rt   Zreadonlyfiler   ru   r   zRassert not %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(exists=%(py4)s)
}r   r   r   r   r   )r   rw   rx   ry   r   r   r   r   r   r   r   r   )	r)   r   r   rv   r   r   r   r    rz   r	   r	   r
   )test_remove_removes_dir_and_readonly_fileM   s    
	     q  z7TestLocalPath.test_remove_removes_dir_and_readonly_filec       	         sv  g    | j  t j j d   f d d    | j     d d } | } | s~ d d t j |  i } t t j |    d  } } x d D] } g    d  d   <| j d |    d d } | | k } | sdt j	 d | f d | | f  d t j |  d d t
 j   k s&t j |  r5t j |  n d i } d d | i } t t j |    d  } } q Wd  S)Nrmtreec                 s     j  |  S)N)append)argskwargs)lr	   r
   <lambda>W   s    z@TestLocalPath.test_remove_routes_ignore_errors.<locals>.<lambda>r   ignore_errorsr   assert not %(py1)spy1TFr5   %(py1)s == %(py3)spy3valassert %(py5)spy5r   )TF)r5   )r   r   )setattrrG   stdshutilry   r   r   r   r   r;   r   r   r   )	r)   r   monkeypatch@py_assert0@py_assert2r>   r   @py_format4@py_format6r	   )r   r
    test_remove_routes_ignore_errorsT   s(    
     
   j   z.TestLocalPath.test_remove_routes_ignore_errorsc       
      C   s  t    } t |  } t j } | j } | j } |   } | | k } | rt j d f | f d f | | f  d d t j	   k p t j
 t  r t j t  n d d t j |  d t j |  d t j |  d d	 t j	   k p t j
 t   rt j t   n d	 d
 t j |  d t j |  d d t j	   k pHt j
 t  rZt j t  n d d t j |  i	 } d d d | i }	 t t j |	    d  } } } } } } } d  S)Nr5   z%(py5)s
{%(py5)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s()
})
} == %(py15)s
{%(py15)s = %(py13)s
{%(py13)s = %(py11)s
{%(py11)s = %(py9)s
{%(py9)s = %(py7)s.std
}.os
}.getcwd
}()
}py7rG   r   r[   r   r   r   r\   r]   r   strr`   r   zassert %(py17)sra   )r   r   rG   r   osgetcwdr   r;   r   r   r   r   r   r   )
r)   r   @py_assert4@py_assert8rm   rn   ro   @py_assert6rp   rq   r	   r	   r
   test_initialize_curdir_   s    	  	 	 	 	    (   z$TestLocalPath.test_initialize_curdirc             C   s  | j  d d d } | j   | j   t j t j j t j j	  | j } |   } d  } | | k } | st
 j d | f d | | f  d t
 j |  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  } } } } t j } |   } t |  }	 | |	 k } | swt
 j d | f d | |	 f  d t
 j |  d d	 t j   k st
 j |  rt
 j |  n d	 d d t j   k st
 j t  rt
 j t  n d d t
 j |	  d d t j   k s*t
 j t  r9t
 j t  n d d
 t
 j |  i } d d | i }
 t t
 j |
    d  } } } }	 d  S)NZdir_to_be_removedr}   rt   isD%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.chdir
}()
} is %(py7)sr   r   r   r   r   r   assert %(py9)sr]   r5   c%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.getcwd
}()
} == %(py9)s
{%(py9)s = %(py6)s(%(py7)s)
}r   r   r   assert %(py11)sr[   )r   )r   r   )r5   )r   r   )rw   chdirry   pytestrj   rG   errorENOENTr*   r   r   r;   r   r   r   r   r   r   r   r   r   )r)   r   r9   r   r   r   r   rz   @py_format10r   @py_format12r	   r	   r
   test_chdir_goneb   s,    

	 	       	 	       zTestLocalPath.test_chdir_gonec             C   s  | j  d d d } t 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 d	 t j   k s t j	 |  r t j
 |  n d	 i } d d | i } t t j |    d  } t j } | j } |   }	 |	 | k }
 |
 st j d |
 f d |	 | f  d t j
 |  d t j
 |	  d d t j   k st j	 t  rt j
 t  n d d d t j   k st j	 |  rt j
 |  n d d t j
 |  i } d d | i } t t j |    d  } } }	 }
 Wd  QRXt j } |   } t |  } | | k }	 |	 sst j d  |	 f d! | | f  d t j
 |  d d	 t j   k st j	 |  rt j
 |  n d	 d d t j   k st j	 t  rt j
 t  n d d t j
 |  d d t j   k s&t j	 t  r5t j
 t  n d d t j
 |  i } d" d | i } t t j |    d  } } }	 } d  S)#Nsubdirr}   rt   r5   %(py0)s == %(py2)sr   xr   oldr   assert %(py4)sr   ^%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.path
}.local
}()
} == %(py8)sr   rG   r   assert %(py10)sr   c%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.getcwd
}()
} == %(py9)s
{%(py9)s = %(py6)s(%(py7)s)
}r   r   r]   r   assert %(py11)sr[   )r5   )r   r   )r5   )r   r   )r5   )r   r   )rw   rG   r*   r   as_cwdr   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
   test_as_cwdk   s6         	 	 	      	 	       zTestLocalPath.test_as_cwdc       
      C   s~  t  j j   } | j d d d } t j t  " | j    t    Wd  QRXWd  QRXt  j } | j } |   } | | k } | sht j	 d | f d | | f  d t j
 |  d t j
 |  d d	 t j   k s t j |  r t j
 |  n d	 d
 t j
 |  d d t j   k s*t j t   r9t j
 t   n d i } d d | i }	 t t j |	    d  } } } } d  S)Nr   r}   rt   r5   ^%(py0)s == %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.path
}.local
}()
}r   r   r   r   r   r   rG   r   assert %(py10)sr   )r5   )r   r   )rG   r*   r   rw   r   rj   rk   r   r   r;   r   r   r   r   r   r   )
r)   r   r   r}   r   r   r    r   r=   r"   r	   r	   r
   test_as_cwd_exceptions   s    	 	 	      z#TestLocalPath.test_as_cwd_exceptionc             C   s   | j     t d  } | j } |   } | s d d d t j |  d d t j   k sk t j |  rz t j |  n d d t j |  i } t t j	 |    d  } } Wd  QRXd  S)Nr   r   z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
}r   r   r9   r   )
r   r   r   r   r   r   r   r   r   r   )r)   r   r9   r   r   r?   r	   r	   r
   test_initialize_reldir{   s    	 	  b  z$TestLocalPath.test_initialize_reldirz4sys.version_info < (2,6) and sys.platform == 'win32'c             C   sp  | j  d t |   t j j d d d } t j } | j } d } | |  } | | k } | sVt j d | f d | | f  d t j	 |  d t j	 |  d	 t j	 |  d
 t j	 |  d d t
 j   k s t j |  r t j	 |  n d d d t
 j   k st j t  r't j	 t  n d i }	 d d |	 i }
 t t j |
    d  } } } } } d  S)NHOME~
expanduserTr5   l%(py0)s == %(py10)s
{%(py10)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.path
}.expanduser
}(%(py8)s)
}r   r   r   r   r   r9   r   r   r   assert %(py12)srC   )r5   )r   r   )setenvr   rG   r*   r   r   r   r   r;   r   r   r   r   r   r   )r)   r   r   r9   r   r   r    r!   r   r"   @py_format13r	   r	   r
   test_tilde_expansion   s    	 	        z"TestLocalPath.test_tilde_expansionc             C   sf  | j  d  } t |  } | | k } | s t j d | f d | | f  d d t j   k so t j |  r~ t j |  n d d d t j   k s t j |  r t j |  n d i } d d
 | i } t t j	 |    d  } | | k } | st j d | f d | | f  d d t j   k s=t j |  rLt j |  n d d d t j   k sst j |  rt j |  n d 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 d t j   k sPt j |  r_t j |  n d i } d d
 | i } t t j	 |    d  } | | k } | s\t j d | f d | | f  d d t j   k st j |  rt j |  n d d d t j   k st j |  r-t j |  n d i } d d
 | i } t t j	 |    d  } d  S)N	sampledirr5   %(py0)s == %(py2)sr   r   r   path2r   assert %(py4)sr   r   !=%(py0)s != %(py2)spath3)r5   )r   r   )r5   )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
   test_eq_with_strings   s6                        z"TestLocalPath.test_eq_with_stringsc             C   s   d  } | | k } | s t  j d	 | f d
 | | f  d d t j   k sZ t  j |  ri t  j |  n d d t  j |  i } d d | i } t t  j |    d  } } d  S)Nr   %(py0)s != %(py3)sr   r   r   r   assert %(py5)sr   )r   )r   r   )r   r;   r   r   r   r   r   r   )r)   r   r   r   r   r   r	   r	   r
   test_eq_with_none   s       j   zTestLocalPath.test_eq_with_nonec          
   C   sS  | j  d  } t | j  d   } | | k } | s t j d | f d | | f  d d t j   k sx t j |  r t j |  n d d d t j   k s t j |  r t j |  n d i } d d | i } t t j	 |    d  } | | k  } | st j d | f d  | | f  d d t j   k sFt j |  rUt j |  n d d d t j   k s|t j |  rt j |  n d i } d! d | i } t t j	 |    d  } 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 |  i } d$ d | i }	 t t 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 i } d' d | i }	 t t j	 |	    d  }
 } | j  d  } | | | g } t
 |  } | | | g } | | k } | sA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 t
  rt j t
  n d d t j |  i } d* d | i } t t j	 |    d  } } } d  S)+Nr   Zttt>%(py0)s > %(py2)sr   r   r   r   r   assert %(py4)sr   <%(py0)s < %(py2)s%(py0)s < %(py3)sr   assert %(py5)sr   %(py1)s > %(py3)sr   Zaaar5   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   r   sortedassert %(py8)sr   )r   )r   r   )r   )r   r   )r   )r   r   )r   )r   r   )r5   )r   r   )r   r   r   r;   r   r   r   r   r   r   r   )r)   r   r   r   r   r>   r?   r   r   r   r   Zpath4r   r   r   @py_format7r=   r	   r	   r
   test_gt_with_strings   sL                 j   
   j   
       z"TestLocalPath.test_gt_with_stringsc       
      C   s.  | j  d d d  } | j d d d  } | j d  Wd  QRX| j } |   } d } | | k } | st j d | f d | | f  d
 t j |  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  } } } } d  S)Nsub1sub2filewrw   rt   rW   r5   C%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read
}()
} == %(py7)sr   r   r   r9   r   r   assert %(py9)sr]   )r5   )r   r   )r   openrf   readr   r;   r   r   r   r   r   r   )
r)   r   r9   fr   r   r   r   rz   r   r	   r	   r
   test_open_and_ensure   s    	 	       z"TestLocalPath.test_open_and_ensurec       	   
   C   s  | j  d d d  } | j d d d | j } |   } d } | | k } | s t j d | f d | | f  d	 t j |  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  } } } } d  S)Nr   r   r   rW   rw   rt   r5   C%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read
}()
} == %(py7)sr   r   r   r9   r   r   assert %(py9)sr]   )r5   )r   r   )r   rf   r   r   r;   r   r   r   r   r   r   )	r)   r   r9   r   r   r   r   rz   r   r	   r	   r
   test_write_and_ensure   s    	 	       z#TestLocalPath.test_write_and_ensurebinFTc       
      C   s@  | j  d t |   } zd d i } | j | d | | j d  } t 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
 d t
 j   k s t j |  r t j |  n d i } d d | i }	 t t j |	    d  } Wd  | j   Xd  S)Nz
dumpfile%sanswer*   r   zrb+r5   %(py0)s == %(py2)sr   dr   dnewr   assert %(py4)sr   )r5   )r   r   )r   r   dumpr   rG   r   pickleloadr   r;   r   r   r   r   r   r   close)
r)   r   r   r*   r   r   r   r   r>   r?   r	   r	   r
   	test_dump   s         
zTestLocalPath.test_dumpc             C   s  d d  l  } d d  l } y) | j   \ } } t j j j |  Wn1 t k
 rt | j   } t	 | d  j   Yn XzOt
 | j    d } t |  } | j } |   } | | 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	 d
 t j   k sEt j |  rTt j |  n d
 d t j |  i }
 d d |
 i } t t j |    d  } } }	 | j |  | j } |   } | | k }	 |	 st j d |	 f d | | f  d t j |  d d t j   k s"t j |  r1t j |  n d d	 d
 t j   k sXt j |  rgt j |  n d
 d t j |  i }
 d d |
 i } t t j |    d  } } }	 | j   | j } |   } | | k }	 |	 st j d |	 f d | | f  d t j |  d d t j   k s2t j |  rAt j |  n d d	 d
 t j   k sht j |  rwt j |  n d
 d t j |  i }
 d d |
 i } t t j |    d  } } }	 Wd  t j j j |  Xd  S)Nr   r   d   r   D%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.mtime
}()
} != %(py6)sr   r   mtimer   r*   r   r   assert %(py8)sr   r5   D%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.mtime
}()
} == %(py6)s)r   )r   r   )r5   )r   r   )r   )r   r   )tempfiletimemkstemprG   r   r   r   AttributeErrormktempr   r   r   r   r   r;   r   r   r   r   r   r   setmtimery   )r)   r   r   fdnamer   r*   r   r   r   r   r=   r	   r	   r
   test_setmtime   sL    	 	      	 	      
	 	      zTestLocalPath.test_setmtimec       	      C   s  | j  d  } | j  d  } t |  } t |  } | | k } | rt j d f | f d f | | f  d d t j   k p t j t  r t j t  n d d t j |  d t j |  d	 d
 t j   k p t j |  r t j |  n d
 d d t j   k pt j |  r*t j |  n d d d t j   k pNt j t  r`t j t  n d i } d d d | i } t t j	 |    d  } } } d  S)Nz	/otherdirotherdirr5   zN%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py8)s
{%(py8)s = %(py5)s(%(py6)s)
}r   r   r   r   r   new1r   new2r   r   zassert %(py10)sr   )
r   r   r   r;   r   r   r   r   r   r   )	r)   r   r  r  r   r    r   r=   r"   r	   r	   r
   test_normpath   s         "   zTestLocalPath.test_normpathc             C   s   t  j   } z | j } d } | d |  } | 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  } } } Wd  | j
 d
 d  Xd  S)Nrt   r}   r   zKassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(dir=%(py4)s)
}r   r   r   r   r   rec)r   mkdtempr   r   r   r   r   r   r   r   ry   )r)   r   r   r   r   r   r	   r	   r
   test_mkdtemp_creation   s    	    q  z#TestLocalPath.test_mkdtemp_creationc             C   s  t  j   } t  j   } z| j } d } | d |  } | 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 } |   } | | k } | st j d | f d | | f  d t j |  d d t j   k sHt j |  rWt j |  n d d d t j   k s~t j |  rt j |  n d d	 t j |  i } d d | i } t	 t j
 |    d  } } } Wd  | j d d  Xd  S)Nrt   r}   r   zKassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(dir=%(py4)s)
}r   r   r   r   r   r5   F%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.dirpath
}()
} == %(py6)stmprootassert %(py8)sr   r	  )r5   )r  r  )r   r
  get_temprootr   r   r   r   r   r   r   r   rJ   r;   ry   )r)   r   r  r   r   r   r   r=   r	   r	   r
   test_tmproot   s&    	    q  	 	      zTestLocalPath.test_tmprootc             C   sL  t    } z1| j   } t |  } t |  } | | k } | rt j d f | f d f | | f  d d t j   k p t j t  r t j t  n d d t j |  d t j |  d d t j   k p t j |  r t j |  n d d	 d
 t j   k pt j |  r$t j |  n d
 d d t j   k pHt j t  rZt j t  n d i } d d d | i } t	 t j
 |    d  } } } t j }	 |	 j }
 |
 j } |   } t |  } | | k } | rt j d f | f d f | | f  d t j |
  d d t j   k p2t j t  rDt j t  n d d d t j   k pht j |  rzt j |  n d d t j |  d t j |  d	 t j |  d d t j   k pt j t  rt j t  n d d t j |	  i } d d d | i } t	 t j
 |    d  }	 }
 } } } } Wd  | j   Xd  S)Nr5   zN%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py8)s
{%(py8)s = %(py5)s(%(py6)s)
}r   r   r   r   r   resr   r   r   r   zassert %(py10)sr   z%(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.std
}.os
}.getcwd
}()
} == %(py13)s
{%(py13)s = %(py10)s(%(py11)s)
}r   r[   r   r\   rG   r   zassert %(py15)sr`   )r   r   r   r   r;   r   r   r   r   r   r   rG   r   r   r   )r)   r   r   r  r   r    r   r=   r"   r   r   r   rn   r!   @py_format14rp   r	   r	   r
   
test_chdir   s2    	     "   	 	 	 	        zTestLocalPath.test_chdirc          
   C   s  | j  d d  } | j   | j } d } | d |  } | 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
 d  | j   | j   } d } | | k } | st j d | f d | | f  d	 d t j   k sQt j |  r`t j |  n d d t j |  i }	 d d |	 i }
 t t j	 |
    d  } } d  S)Ntest1ri   rt   r   r   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(file=%(py4)s)
}r   r   r   newfiler   42r5   %(py0)s == %(py3)ssr   assert %(py5)sr   )r5   )r  r  )r   rw   r   r   r   r   r   r   r   r   rf   r   r;   )r)   r   r  r   r   r   r   r  r   r   r   r	   r	   r
   test_ensure_filepath_withdir   s&    
	    q  
   j   z*TestLocalPath.test_ensure_filepath_withdirc       
   
   C   s  | j  d  } | j   } | | k } | s t j d | f d | | f  d d t j   k so t j |  r~ t j |  n d d d t j   k s t j |  r t j |  n d i } d d
 | i } t t j	 |    d  } | j
 } d } | d |  } | sd d d
 t j |  d t j |  d d t j   k sVt j |  ret j |  n d d t j |  i }	 t t j	 |	    d  } } } d  S)NZ	test1filer5   %(py0)s == %(py2)sr   tr   r  r   assert %(py4)sr   rt   r   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(file=%(py4)s)
}r   )r5   )r  r  )r   rw   r   r;   r   r   r   r   r   r   r   )
r)   r   r  r  r   r>   r?   r   r   r   r	   r	   r
   test_ensure_filepath_withoutdir   s         	    q  z-TestLocalPath.test_ensure_filepath_withoutdirc       
   
   C   s  | j  d d  } | j d d  } | | k } | s t j d | f d | | f  d d t j   k sx t j |  r t j |  n d d	 d
 t j   k s t j |  r t j |  n d
 i } d d | i } t t j	 |    d  } | j
 } d } | d |  } | sd d d t j |  d t j |  d d
 t j   k s_t j |  rnt j |  n d
 d	 t j |  i }	 t t j	 |	    d  } } } d  S)Nr  Ztestfiler}   rt   r5   %(py0)s == %(py2)sr   r  r   r  r   assert %(py4)sr   zKassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(dir=%(py4)s)
}r   )r5   )r  r   )r   rw   r   r;   r   r   r   r   r   r   r   )
r)   r   r  r  r   r>   r?   r   r   r   r	   r	   r
   test_ensure_dirpath   s         	    q  z!TestLocalPath.test_ensure_dirpathc          
   C   s  t    } t  |  } | | k } | s t j d | f d | | f  d d t j   k si t j |  rx t j |  n d d d t j   k s t j |  r t j |  n d i } d d	 | i } t t j |    d  } t	 j
 j d
  } t  |  } | | k	 } | st j d | f d | | f  d d t j   k sUt j |  rdt j |  n d d d t j   k st j |  rt j |  n d i } d d	 | i } t t j |    d  } | j } | j }	 | |	 k }
 |
 st j d |
 f d  | |	 f  d	 d t j   k s5t j |  rDt j |  n d d t j |	  d d t j   k szt j |  rt j |  n d d t j |  i } d! d | i } t t j |    d  } }
 }	 d } t | |  } | } | sd d d d t j   k s"t j |  r1t j |  n d d t j |  d d t j   k sgt j t  rvt j t  n d d t j |  i } t t j |    d  } } } d  S)"Nr5   %(py0)s == %(py2)sr   l2r   r   r   assert %(py4)sr   r4   is not%(py0)s is not %(py2)sl3wcL%(py2)s
{%(py2)s = %(py0)s.strpath
} == %(py6)s
{%(py6)s = %(py4)s.strpath
}r   assert %(py8)sr   commitz9assert not %(py5)s
{%(py5)s = %(py0)s(%(py1)s, %(py3)s)
}r   r   hasattrr   )r5   )r"  r$  )r%  )r&  r$  )r5   )r)  r*  )r   r   r;   r   r   r   r   r   r   rG   r*   svnwcstrpathr,  )r)   r   r   r#  r   r>   r?   r(  r'  r   r   r   r=   r   r   r   r	   r	   r
   test_init_from_path   s>    	          	 	            z!TestLocalPath.test_init_from_pathrunreasonz!unreliable est for long filenamesc          
   C   sQ  t  j d k r t j j d  d d } | j |  } | j d d  | j d  | j |  } | j } |   } d } | | k } | s;t	 j
 d | f d | | f  d
 t	 j |  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  } } } } d  S)Nwin32z/win32: work around needed for path length limitz/test<   r   TrA   r5   C%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read
}()
} == %(py7)sr   r   r   r#  r   r   assert %(py9)sr]   )r5   )r4  r5  )sysplatformrG   ri   skipr   rw   rf   r   r   r;   r   r   r   r   r   r   )r)   r   Znewfilenamer   r#  r   r   r   r   rz   r   r	   r	   r
   test_long_filenames  s     
	 	       z!TestLocalPath.test_long_filenamesc          
   C   s  | j  d d  } | j  d d  } | j  d  } t | j d d     } t |  } d } | | k } | sF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 t  rt j	 t  n d d t j	 |  i }	 d d |	 i }
 t
 t 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 i } d d | i } t
 t j |    d  } } d  S)Na1b2Zbreadthc             S   s   |  j  d d  S)Nr   rt   )r   )r   r	   r	   r
   r     s    z6TestLocalPath.test_visit_depth_first.<locals>.<lambda>   r5   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   r   r   r   lenr   r   assert %(py8)sr      %(py1)s == %(py3)sp3assert %(py5)sr   )r5   )r?  rA  )r5   )rC  rE  )rw   listvisitr@  r   r;   r   r   r   r   r   r   )r)   r   p1p2rD  r   r   r   r   r   r=   r   r   r   r	   r	   r
   test_visit_depth_first  s&           
   j   z$TestLocalPath.test_visit_depth_firstc          
   C   s  | j  d d  } | j  d d  } t | j d d d  } t |  } d } | | k } | s7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 t  r t j	 t  n d d t j	 |  i } d d | i }	 t
 t 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 i } d d | i } t
 t j |    d  }
 } d  S)Nr:  123z.bZ345z???r	  z[!.]*rt   r5   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   r   r   r   r@  r   r   assert %(py8)sr   r   %(py1)s == %(py3)srH  assert %(py5)sr   )r5   )rL  rM  )r5   )rN  rO  )rw   rF  rG  r@  r   r;   r   r   r   r   r   r   )r)   r   rH  rI  r   r   r   r   r   r=   r   r   r   r	   r	   r
   test_visit_rec_fnmatch!  s$           
   j   z$TestLocalPath.test_visit_rec_fnmatchc             C   sK  | j  d d  } | j } t j } | j  } d } | |  } | |  } | s:d d d t j |  d t j |  d t j |  d	 d
 t j   k s t j t  r t j t  n 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  } } } } } } t j j  t |  d d g  }
 | j } | |
  } | s=d d d t j |  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 i } t	 t j
 |    d  } } d  S)Nr:  r<  abr   zassert %(py13)s
{%(py13)s = %(py2)s
{%(py2)s = %(py0)s.fnmatch
}(%(py11)s
{%(py11)s = %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.sep
}.join
}(%(py9)s)
})
}r   r   r[   r   r   r\   r]   r   r   *zIassert %(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.fnmatch
}(%(py3)s)
}pattern)r   fnmatchr   sepr   r   r   r   r   r   r   r   )r)   r   r<  r   r   r   r   rm   rn   r  rS  r   r	   r	   r
   test_fnmatch_file_abspath)  s$    	 	 	       !	     z'TestLocalPath.test_fnmatch_file_abspathc             C   s  t  j d k r d p d } t j j j |  } | j } d } | d |  } | 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  } } } t j } | j } | j } d } | |  } d  }	 | |	 k }
 |
 st j d# |
 f d$ | |	 f  d t j |  d t j |  d t j |  d t j |	  d	 t j |  d
 d t	 j
   k st j t  rt j t  n d d t j |  i } d% d | i } t t j |    d  } } } } } }
 }	 t j } | j } | j } g  } | | 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 |  d
 d t	 j
   k s3t j t  rBt j t  n d d t j |  i } d( d | i } t t j |    d  } } } } } }	 } t j j j | d | j   g } | | k } | st j d) | f d* | | f  d
 d! t	 j
   k st j |  r%t j |  n d! d d t	 j
   k sLt j |  r[t j |  n d i } d+ d | i } t t j |    d  } d  S),Nr2  cmdri   rt   r   r   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(file=%(py4)s)
}r   r   r   r   r   jaksdkasldqwer   %(py10)s
{%(py10)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.path
}.local
}.sysfind
}(%(py8)s)
} is %(py13)sr   r   r\   rG   assert %(py15)sr`   paths%(py11)s
{%(py11)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.path
}.local
}.sysfind
}(%(py7)s, paths=%(py9)s)
} is %(py14)sr   r  r[   rD   r]   assert %(py16)srE   r5   %(py0)s == %(py2)sx2assert %(py4)s)r   )rY  rZ  )r   )r\  r]  )r5   )r^  r`  )r6  r7  rG   r*   r   sysfindr   r   r   r   r   r   r   r   r;   rJ   )r)   r  r   r   r   r   r   r    r!   rn   rK   r  rp   r   rm   rL   rM   rN   r_  r>   r?   r	   r	   r
   test_sysfind/  sP    	    q  	 	 	         	 	 	         $     zTestLocalPath.test_sysfindc             C   s@  t  j j |  } | j   } | j } | d |  } | r d d d t j |  d d t j   k pt t j	 |  r t j |  n d d t j |  d d	 t j   k p t j	 |  r t j |  n d	 i } t
 t j |    d  } } | j } | |  } | j } t j } | j }	 | j }
 |	 |
 |  } | | k } | rt j d
 f | f d f | | f  d t j |  d d t j   k pt j	 |  rt j |  n d d d t j   k pt j	 |  rt j |  n d d d	 t j   k pt j	 |  r!t j |  n d	 d t j |	  d t j |
  d t j |  d t j |  d t j |  d d t j   k pt j	 t  rt j t  n d d d t j   k pt j	 |  rt j |  n d d t j |  i } d d d | i } t
 t j |    d  } } } } } }	 }
 } d  S)Nendswithr   zPassert %(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.check
}(endswith=%(py3)s)
}r   r   py_pathr   r   str_pathr5   z%(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py3)s)
}.strpath
} == %(py19)s
{%(py19)s = %(py13)s
{%(py13)s = %(py11)s
{%(py11)s = %(py9)s.path
}.join
}(%(py16)s
{%(py16)s = %(py14)s.strpath
}, %(py17)s)
}r   rD   fake_fspath_objra   r\   rE   r[   r]   r   py19zassert %(py21)spy21)rG   r*   r   r,   r   r   r   r   r   r   r   r   r   r.  r   r;   )r)   rf  rd  re  r   r   r   r   rm   rn   rO   @py_assert18r   @py_format20@py_format22r	   r	   r
    test_fspath_protocol_other_class8  s,    	     
	  	 	 	 	        z.TestLocalPath.test_fspath_protocol_other_classN)FT)-r-   r.   r/   r@   skiponwin32rR   rr   r{   r   r   r   r   r   r   r   r   r   markxfailr   r   r   r   r   r   rG   ri   multir   failsonjywin32r  r  r  r  r  r  r  r!  r/  r9  rJ  rP  rV  rb  rl  r	   r	   r	   r
   r3   (   sD   		$			*		r3   c               @   s"   e  Z d  Z e Z d d   Z d S)TestExecutionOnWindowsc             C   s"  | j  d t |  d t j | j d  | j d  } t 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	 d
 t j   k s t	 j |  r t	 j |  n d
 i } d d | i } t t	 j |    d  } d  S)NPATHprependrW   z	hello.batr5   %(py0)s == %(py2)sr   r   r   hr   assert %(py4)sr   )r5   )ru  rw  )r   r   r   pathseprw   rG   r*   r   ra  r   r;   r   r   r   r   r   r   )r)   r   r   rv  r   r   r>   r?   r	   r	   r
   test_sysfind_bat_exe_beforeD  s         z2TestExecutionOnWindows.test_sysfind_bat_exe_beforeN)r-   r.   r/   	win32only
pytestmarkry  r	   r	   r	   r
   rr  A  s   rr  c               @   s   e  Z d  Z e 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)TestExecutionc             C   sy  | j  d d d } | j d | d d | j d  t j } | j } | j } d } | |  } d  }	 | |	 k }
 |
 sWt j d |
 f d | |	 f  d t j	 |  d t j	 |  d t j	 |  d t j	 |	  d t j	 |  d d t
 j   k s
t j t  rt j	 t  n d d t j	 |  i } d d | i } t t j |    d  } } } } } }
 }	 d  S)Nnopermr}   Trs  rt  :r   rX  r   %(py10)s
{%(py10)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.path
}.local
}.sysfind
}(%(py8)s)
} is %(py13)sr   r   r   r\   r   r   rG   r   r   assert %(py15)sr`   )r   )r  r  )rw   r   rx   rG   r*   r   ra  r   r;   r   r   r   r   r   r   )r)   r   r   r}  r   r   r   r    r!   rn   rK   r  rp   r	   r	   r
   !test_sysfind_no_permisson_ignoredO  s    	 	 	         z/TestExecution.test_sysfind_no_permisson_ignoredc       	   
   C   sr  t  j j j d  } | j } d } | d |  } | 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  } } } t  j j j t |   } | j } d } | d |  } | sd d d t j |  d t j |  d d t j   k sUt j	 |  rdt j |  n d d
 t j |  i } t
 t j |    d  } } } | | k } | sht j d | f d | | f  d d t j   k st j	 |  rt j |  n d d
 d	 t j   k s*t j	 |  r9t j |  n d	 i } d d | i } t
 t j |    d  } d  S)Nri   rt   r   r   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(file=%(py4)s)
}r   r   r   r   r   yr5   %(py0)s == %(py2)sassert %(py4)s)r5   )r  r  )rG   r*   r   ra  r   r   r   r   r   r   r   r   r   r;   )	r)   r   r   r   r   r   r  r>   r?   r	   r	   r
   test_sysfind_absoluteU  s,    	    q  	    q       z#TestExecution.test_sysfind_absolutec             C   s  | j  d d | j d  | j d  f d d | j d d  d d   } t j j j d d	 | } | j } 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
 |  i } d# d | i }	 t t j |	    d  } } } | j } |   } | j }
 d } |
 | k } | s%t j	 d$ | f d% |
 | f  d t j
 |  d t j
 |
  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  } } }
 } } d d   } t j } | j } | j }
 d } |
 | d	 | } d  } | | k } | st j	 d' | f d( | | f  d t j
 |  d t j
 |  d t j
 |  d t j
 |  d t j
 |
  d d	 t j   k st j |  r.t j
 |  n d	 d d t j   k sUt j t  rdt j
 t  n d d t j
 |  i } d) d  | i } t t j |    d  } } }
 } } } } d  S)*Nrs  z%s:%sr:  r<  rt  r~  c             S   s   |  j    j d k S)Nr<  )rJ   r<   )r   r	   r	   r
   r   b  s    z5TestExecution.test_sysfind_multiple.<locals>.<lambda>checkerr5   0%(py2)s
{%(py2)s = %(py0)s.basename
} == %(py5)sr   r   r   r   r   assert %(py7)sr   d%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.dirpath
}()
}.basename
} == %(py9)sr   r   r]   assert %(py11)sr[   c             S   s   d  S)Nr	   )r   r	   r	   r
   r   f  s    r   %(py11)s
{%(py11)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.path
}.local
}.sysfind
}(%(py8)s, checker=%(py9)s)
} is %(py14)sr   rD   rG   assert %(py16)srE   )r5   )r  r  )r5   )r  r  )r   )r  r  )r   rw   r   rG   r*   r   ra  r<   r   r;   r   r   r   r   r   r   rJ   )r)   r   r   r  r   r   r   r   r   rz   r   r   r    r   r   rm   rL   rn   rM   rN   r	   r	   r
   test_sysfind_multiple\  sL    		    y   	 	 	       	 	 	         z#TestExecution.test_sysfind_multiplec             C   s  t  j j j d  } | j d  } xft  j j   j   D]O} | j } | j } | |  } d } | } | | k } | sot j	 d | f d | | f  d t j
 |  d t j
 |  d t j
 |  d	 d
 t j   k s t j |  r t j
 |  n d
 d d t j   k s"t j |  r1t j
 |  n d d t j
 |  i }	 d d |	 i }
 t t j |
    d  } } } } } } q: Wd  S)NZlsz-art   r   j%(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.find
}(%(py5)s
{%(py5)s = %(py3)s.basename
})
} != -%(py10)sr   r   r   r   r   r   outr   r   assert %(py13)sr\   )r   )r  r  )rG   r*   r   ra  sysexeclistdirfindr<   r   r;   r   r   r   r   r   r   )r)   r   r  r   r   r   r!   rK   r   r   r  r	   r	   r
   test_sysexeci  s    	 	         zTestExecution.test_sysexecc             C   s5   t  j j j d  } t  j j t  j j j d  d  S)Nfalsez-
            x.sysexec('aksjdkasjd')
        )	rG   r*   r   ra  ri   rj   processcmdexecError)r)   r   r	   r	   r
   test_sysexec_failingo  s    z"TestExecution.test_sysexec_failingc             C   s  | j  d d d xt d  D]} t j d d d | d d	 d
 d  } | j } |   } | r d d d t j |  d d t j   k p t j	 |  r t j |  n d d t j |  i } t
 t j |    d  } } | j } d } | | } | | k } | rt j d f | f d f | | f  d d t j   k pUt j	 |  rgt j |  n d d t j |  d d t j   k pt j	 |  rt j |  n d d t j |  i }	 d d d |	 i }
 t
 t j |
    d  } } } } | d k r| j } d } | | } t |  } | d |  } | j } |   } | rxd d d d t j   k pt j	 |  rt j |  n d d t j |  d d t j   k pt j	 t  rt j t  n d d t j |  d t j |  d t j |  d d t j   k p)t j	 |  r;t j |  n d d t j |  d  t j |  i	 } t
 t j |    d  } } } } } } } | d	 k r,| j } d	 } | | } t |  } | d |  } | j } |   } | rd d d d t j   k pt j	 |  r)t j |  n d d t j |  d d t j   k p\t j	 t  rnt j t  n d d t j |  d t j |  d t j |  d d t j   k pt j	 |  rt j |  n d d t j |  d  t j |  i	 } t
 t j |    d  } } } } } } } | d! k r| j } d! } | | } t |  } | d |  } | j } |   } | } | rd d" d d t j   k pt j	 |  rt j |  n d d t j |  d d t j   k pt j	 t  rt j t  n d d t j |  d t j |  d t j |  d d t j   k p\t j	 |  rnt j |  n d d t j |  d  t j |  i	 } t
 t j |    d  } } } } } } } } q  Wd  S)#Nzbase.not_an_intr}   rt   
   prefixzbase.rootdirkeeprB  lock_timeoutr   r   z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
}r   r   numdirr   zbase.%dr5   z=%(py2)s
{%(py2)s = %(py0)s.basename
} == (%(py5)s %% %(py6)s)r   ir   zassert %(py9)sr]   extzassert %(py15)s
{%(py15)s = %(py13)s
{%(py13)s = %(py11)s
{%(py11)s = %(py2)s
{%(py2)s = %(py0)s.new
}(ext=%(py9)s
{%(py9)s = %(py3)s((%(py4)s - %(py6)s))
})
}.check
}()
}r[   r   r   r\   r`   r>  zassert not %(py15)s
{%(py15)s = %(py13)s
{%(py13)s = %(py11)s
{%(py11)s = %(py2)s
{%(py2)s = %(py0)s.new
}(ext=%(py9)s
{%(py9)s = %(py3)s((%(py4)s - %(py6)s))
})
}.check
}()
})rw   ranger   make_numbered_dirr   r   r   r   r   r   r   r   r<   r;   newr   )r)   r   r  r  r   r   r?   r   r    rz   r   r   r   rm   rn   ro   rp   @py_assert16rN   r	   r	   r
   test_make_numbered_diru  sv    	 	  b  
	  
      	  
   	 	     	  
   	 	     	  
   	 	      z$TestExecution.test_make_numbered_dirc       
   
   C   s  d d   } | j  t j j d |  | j d | d d  } | j } | |  } | sd d d	 t j |  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 i } t t j |    d  } } | j } |   } | sd d d t j |  d
 d t j	   k sat j
 |  rpt j |  n d d t j |  i }	 t t j |	    d  } } d  S)Nc             S   s   t  d   d  S)Nr   )NotImplementedError)r   r  r	   r	   r
   notimpl  s    zJTestExecution.test_make_numbered_dir_NotImplemented_Error.<locals>.notimplsymlinkr  r  r   r   zGassert %(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.relto
}(%(py3)s)
}r   r   r   r   r   r   z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
}r   )r   rG   r   r   r  reltor   r   r   r   r   r   r   r   )
r)   r   r   r  r   r   r   r   r   r?   r	   r	   r
   +test_make_numbered_dir_NotImplemented_Error  s    	     
	 	  b  z9TestExecution.test_make_numbered_dir_NotImplemented_Errorc             C   s\  xUt  d  D]G} t j d d d | d d  } | j } |   } | s d d 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 } d } | | } | | k } | st j d | f d | | f  d d t j   k s7t j |  rF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  } } } } xvt  |  D]h} | j } t |  } | d |  } | j } |   } | s:d d d	 d t j   k sUt j |  rdt j |  n d d t j |  d t j |  d t j |  d d t j   k st j t  rt j t  n d d t j |  d
 d t j   k st j |  rt j |  n d d t j |  i } t	 t j
 |    d  } } } } } qWq Wd  S) Nr  r  zbase2.r  r  rB  r   z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
}r   r   r  r   zbase2.%dr5   =%(py2)s
{%(py2)s = %(py0)s.basename
} == (%(py5)s %% %(py6)s)r   r  r   assert %(py9)sr]   r  zassert %(py12)s
{%(py12)s = %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py2)s
{%(py2)s = %(py0)s.new
}(ext=%(py6)s
{%(py6)s = %(py3)s(%(py4)s)
})
}.check
}()
}jr   rC   r   r   r   )r5   )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    rz   r   r  r   r!   rK   r   r	   r	   r
   test_locked_make_numbered_dir  s8    		 	  b  
	  
      	   	 	    z+TestExecution.test_locked_make_numbered_dirc             C   sB   t  j j t | j d  j  t  j j t | j d  j  d  S)NZqwoeqiwe)rG   ri   rj   EnvironmentErrorr   r   r   )r)   r   r	   r	   r
   test_error_preservation  s    z%TestExecution.test_error_preservationN)r-   r.   r/   rm  r{  r  r  r  r  r  r  r  r  r  r	   r	   r	   r
   r|  L  s   	r|  c               @   s   e  Z 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)
TestImportc             C   s  | j  d  j   } | j } 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 |  i } d d | i } t	 t j
 |    d  } } } | j } d } | | k } | st j d | f d | | f  d t j |  d d t j   k sTt j |  rct j |  n d d t j |  i } d d | i } t	 t j
 |    d  } } } d  S)Nzexecfile.pyr   r5   )%(py2)s
{%(py2)s = %(py0)s.x
} == %(py5)sr   r   objr   r   assert %(py7)sr   execfile0%(py2)s
{%(py2)s = %(py0)s.__name__
} == %(py5)s)r5   )r  r  )r5   )r  r  )r   pyimportr   r   r;   r   r   r   r   r   r   r-   )r)   r   r  r   r   r   r   rz   r	   r	   r
   test_pyimport  s"    	    y   	    y   zTestImport.test_pyimportc                s^     j  d d  } | j     j d  j   j d   t j   j   f d d    d  S)Nr:  ztest_x123.pyr<  c                  s     j  d d  j   S)Nr<  ztest_x123.py)r   r  r	   )r   r	   r
   r     s    zGTestImport.test_pyimport_renamed_dir_creates_mismatch.<locals>.<lambda>)rw   r  r   mover   rj   ImportMismatchError)r)   r   r9   r	   )r   r
   *test_pyimport_renamed_dir_creates_mismatch  s
    
z5TestImport.test_pyimport_renamed_dir_creates_mismatchc             C   s   | j  d  } | j   } d  S)Nzfoo__init__.py)rw   r  )r)   r   r*   r  r	   r	   r
   test_pyimport_messy_name  s    z#TestImport.test_pyimport_messy_namec       
      C   s  | j  d  } | j d  } | j   } | j } 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 |  i } d d | i }	 t
 t j |	    d  } } } | j   } | j } d } | | k } | st j d | f d | | f  d t j |  d d t j   k sut j	 |  rt j |  n d d t j |  i } d d | i }	 t
 t j |	    d  } } } d  S)NZ	hello_123z__init__.pyr5   0%(py2)s
{%(py2)s = %(py0)s.__name__
} == %(py5)sr   r   mr   r   assert %(py7)sr   )r5   )r  r  )r5   )r  r  )r   rw   r  r-   r   r;   r   r   r   r   r   r   )
r)   r   r9   Zp_initr  r   r   r   r   rz   r	   r	   r
   test_pyimport_dir  s(    	    y   	    y   zTestImport.test_pyimport_dirc             C   s  | j  d  j d d  } | j } 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 |  i } d d | i } t	 t j
 |    d  } } } | j } d } | | k } | st j d | f d | | f  d t j |  d d	 t j   k sZt j |  rit j |  n d	 d
 t j |  i } d d | i } t	 t j
 |    d  } } } d  S)Nzexecfile.pymodnamez0x.y.zr   r5   )%(py2)s
{%(py2)s = %(py0)s.x
} == %(py5)sr   r   r  r   r   assert %(py7)sr   0%(py2)s
{%(py2)s = %(py0)s.__name__
} == %(py5)s)r5   )r  r  )r5   )r  r  )r   r  r   r   r;   r   r   r   r   r   r   r-   )r)   r   r  r   r   r   r   rz   r	   r	   r
   %test_pyimport_execfile_different_name  s"    	    y   	    y   z0TestImport.test_pyimport_execfile_different_namec       	      C   s  | j  d  } | j  d  j   } | j } 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 |  i } d d | i } t	 t j
 |    d  } } } | j } d } | | k } | st j d | f d | | f  d t j |  d d t j   k sct j |  rrt j |  n d d	 t j |  i } d d | i } t	 t j
 |    d  } } } d  S)Nr  za.pyzgot itr5   .%(py2)s
{%(py2)s = %(py0)s.result
} == %(py5)sr   r   modr   r   assert %(py7)sr   z
otherdir.a0%(py2)s
{%(py2)s = %(py0)s.__name__
} == %(py5)s)r5   )r  r  )r5   )r  r  )r   r  resultr   r;   r   r   r   r   r   r   r-   )	r)   r   r  r  r   r   r   r   rz   r	   r	   r
   test_pyimport_a  s$    	    y   	    y   zTestImport.test_pyimport_ac       	      C   s  | j  d  } | j  d  j   } | j } 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 |  i } d d | i } t	 t j
 |    d  } } } | j } d } | | k } | st j d | f d | | f  d t j |  d d t j   k sct j |  rrt j |  n d d	 t j |  i } d d | i } t	 t j
 |    d  } } } d  S)Nr  zb.pyzgot itr5   -%(py2)s
{%(py2)s = %(py0)s.stuff
} == %(py5)sr   r   r  r   r   assert %(py7)sr   z
otherdir.b0%(py2)s
{%(py2)s = %(py0)s.__name__
} == %(py5)s)r5   )r  r  )r5   )r  r  )r   r  stuffr   r;   r   r   r   r   r   r   r-   )	r)   r   r  r  r   r   r   r   rz   r	   r	   r
   test_pyimport_b  s$    	    y   	    y   zTestImport.test_pyimport_bc       	      C   s   | j  d  } | j  d  j   } | j } 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 |  i } d d | i } t	 t j
 |    d  } } } d  S)Nr  zc.pyzgot itr5   -%(py2)s
{%(py2)s = %(py0)s.value
} == %(py5)sr   r   r  r   r   assert %(py7)sr   )r5   )r  r  )r   r  valuer   r;   r   r   r   r   r   r   )	r)   r   r  r  r   r   r   r   rz   r	   r	   r
   test_pyimport_c  s    	    y   zTestImport.test_pyimport_cc       	      C   s   | j  d  } | j  d  j   } | j } 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 |  i } d d | i } t	 t j
 |    d  } } } d  S)Nr  zd.pyzgot itr5   .%(py2)s
{%(py2)s = %(py0)s.value2
} == %(py5)sr   r   r  r   r   assert %(py7)sr   )r5   )r  r  )r   r  value2r   r;   r   r   r   r   r   r   )	r)   r   r  r  r   r   r   r   rz   r	   r	   r
   test_pyimport_d  s    	    y   zTestImport.test_pyimport_dc             C   s  | j  d d  | j  d d  } | j   } | j } 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 |  i } d d | i } t	 t j
 |    d  } } } d d l m }	 |	 | k } | st j d | f d |	 | f  d d t j   k s_t j |	  rnt j |	  n d d
 d	 t j   k st j |  rt j |  n d	 i }
 d d |
 i } t	 t j
 |    d  } d  S)N
xxxpackagez__init__.pyz
module1.pyzxxxpackage.module1r5   0%(py2)s
{%(py2)s = %(py0)s.__name__
} == %(py5)sr   r   mod1r   r   assert %(py7)sr   r   )module1r   %(py0)s is %(py2)sr  assert %(py4)sr   )r5   )r  r  )r   )r  r  )rw   r  r-   r   r;   r   r   r   r   r   r   r  r  )r)   r   Zmod1pathr  r   r   r   r   rz   r  r>   r?   r	   r	   r
   test_pyimport_and_import  s$    	    y        z#TestImport.test_pyimport_and_importc             C   sN  d } t  t j j  } | j | d  } x,d D]$} | |  } | j | |  } t |  | _ | j t j	 | |  | j
   }	 | |	 k }
 |
 sPt j d |
 f d | |	 f  d d	 t j   k s t j |  r t j |  n d	 d
 d t j   k st j |	  r!t j |	  n d i } d  d | i } t t j |    d  }
 q2 W| j   | |  } | j | d  } t |  | _ | j t j	 | |  t j j | j d  } | j j \ } } } | | k }
 |
 st j d! |
 f d" | | f  d d t j   k s)t j |  r8t j |  n d d
 d t j   k s_t j |  rnt j |  n d i } d# d | i } t t j |    d  }
 | | k }
 |
 skt j d$ |
 f d% | | f  d d t j   k st j |  rt j |  n d d
 d t j   k s-t j |  r<t j |  n d i } d& d | i } t t j |    d  }
 | | k }
 |
 s9t j d' |
 f d( | | f  d d t j   k st j |  rt j |  n d d
 d t j   k st j |  r
t j |  n d i } d) d | i } t t j |    d  }
 | j } t | t  } | s@d d d d t j   k st j |  rt j |  n d d d t j   k st j t  rt j t  n d d t j |  d d t j   k st j t  rt j t  n d d t j |  i } t t j |    d  } } d  S)*NZpointsback123z.py.pyc	$py.class.pyor5   %(py0)s == %(py2)sr   r  r   newmodr   assert %(py4)sr   z123.pyzp.pyimport()r  r  modfile
pseudopathorigr9   z^assert %(py6)s
{%(py6)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s.ImportMismatchError
}, %(py4)s)
}r   ImportErrorr   
issubclassr   )r  r  r  )r5   )r  r  )r5   )r  r  )r5   )r  r  )r5   )r  r  )typerG   r   r   rw   r   __file__setitemr6  modulesr  r   r;   r   r   r   r   r   r   undori   rj   r  r  r   r  r  )r)   r   r   r  
ModuleTyper9   Zendingr  r  r  r   r>   r?   excinfor  r  r  r   r   r   r	   r	   r
   (test_pyimport_check_filepath_consistency  s^         

	               	     z3TestImport.test_pyimport_check_filepath_consistencyc       	      C   s  | j  d d  } | j  d d d  } | j   } | j   } | | k } | st j d | f d | | f  d d t j   k s t j |  r t j |  n d d d	 t j   k s t j |  r t j |  n d	 i } d d | i } t t j	 |    d  } d  S)NZprojaz__init__.pysubr5   %(py0)s == %(py2)sr   m1r   m2r   assert %(py4)sr   )r5   )r  r  )
rw   r  r   r;   r   r   r   r   r   r   )	r)   r   rH  rI  r  r  r   r>   r?   r	   r	   r
   !test_issue131_pyimport_on__init__  s         z,TestImport.test_issue131_pyimport_on__init__c             C   s  | j  d  } | j d  } t |  } t j } | | 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 d t j   k s t j	 t  r t j
 t  n d d	 d
 t j   k st j	 t  rt j
 t  n d
 d t j
 |  i } d d | i } t t j |    d  } } } | j d d  t |  } t j d }	 | |	 k } | sl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	 t  r.t j
 t  n d
 d t j
 |  i }
 d d |
 i } t t j |    d  } } }	 t |  } t j d  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	 d
 t j   k s2t j	 t  rAt j
 t  n d
 d t j
 |  i }
 d" d |
 i } t t j |    d  } } }	 d  S)#Nroot1zx123.pynot inN%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} not in %(py7)s
{%(py7)s = %(py5)s.path
}r   r   r   r6  r   r   r   r   assert %(py9)sr]   ensuresyspathr   rt   r5   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   assert %(py8)sr   4%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} not in %(py6)s)r  )r  r  )r5   )r   r  r  )r  )r  r  )mkdirrw   r   r6  r*   r   r;   r   r   r   r   r   r   r  )r)   r   r  Zfile1r   r   r   rz   r   r   r   r=   r	   r	   r
   test_ensuresyspath_append  s6     	                    z$TestImport.test_ensuresyspath_appendN)r-   r.   r/   r  r  r  r  r  r  r  r  r  r  r  r  r  r	   r	   r	   r
   r    s   
r  c             C   s  |  j  d d d } | j  d  | j  d  | j } |   } | | 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 d
 t j   k s t j |  r t j |  n d
 d t j |  i } d d | i } t t j	 |    d  } } } | j
 } d } d } | | |  } | j } |   }	 |	 | k }
 |
 st j d |
 f d |	 | f  d t j |  d t j |  d t j |	  d t j |  d d
 t j   k st j |  r
t j |  n d
 d	 t j |  d d
 t j   k s@t j |  rOt j |  n d
 d t j |  i } d d | i } t t j	 |    d  } } } } } }	 }
 d  S)NZpkg1r}   rt   z__init__.pyzsubdir/__init__.pyr5   H%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.pypkgpath
}()
} == %(py6)sr   r   pkgr   r   r   assert %(py8)sr   r   %(py12)s
{%(py12)s = %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py4)s, %(py6)s)
}.pypkgpath
}()
} == %(py14)sr   rC   rD   assert %(py16)srE   )r5   )r  r  )r5   )r	  r
  )rw   	pypkgpathr   r;   r   r   r   r   r   r   r   )r   r  r   r   r   r   r=   r    r!   rK   rL   rM   rN   r	   r	   r
   test_pypkgdir  s.    	 	      	    	 	      r  c             C   s?  |  j  d d d } | j  d  | j  d  j   } | j } |   } | | 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 d
 t j   k s t j |  r t j |  n d
 d t j |  i } d d | i } t	 t j
 |    d  } } } | j  } d } | |  } | j } |   }	 |	 | k }
 |
 s}t j d |
 f d |	 | f  d t j |  d t j |	  d d
 t j   k st j |  rt j |  n d
 d t j |  d	 t j |  d d
 t j   k s0t j |  r?t j |  n d
 d t j |  i } d d | i } t	 t j
 |    d  } } } } }	 }
 | j } |   } | } | s-d d d t j |  d d t j   k st j |  rt j |  n d d t j |  i } t	 t j
 |    d  } } } d  S)Nzpkg1-1r}   rt   z__init__.pyzsubdir/__init__.pyr5   H%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.pypkgpath
}()
} == %(py6)sr   r   r   r   r   r   assert %(py8)sr   zxyz.py%(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.ensure
}(%(py4)s)
}.pypkgpath
}()
} == %(py12)sr   rC   assert %(py14)srD   zHassert not %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.pypkgpath
}()
}r  )r5   )r  r  )r5   )r  r  )rw   rJ   r  r   r;   r   r   r   r   r   r   )r   r  r   r   r   r   r   r=   r    r!   rK   r   rM   r   r	   r	   r
   test_pypkgdir_unimportable  s:    	 	      	   	 	      	 	   b  r  c              C   s  d d l  m }  d } |  |  } | } | s d d d t j |  d d t j   k si t j |   rx t j |   n d d t j |  i } t t j |    d  } } } d	 } |  |  } | sCd d
 d t j |  d d t j   k st j |   rt j |   n d d t j |  i } t t j |    d  } } d } |  |  } | sd d
 d t j |  d d t j   k st j |   rt j |   n d d t j |  i } t t j |    d  } } d } |  |  } | sud d
 d t j |  d d t j   k s8t j |   rGt j |   n d d t j |  i } t t j |    d  } } d } |  |  } | sd d
 d t j |  d d t j   k st j |   rt j |   n d d t j |  i } t t j |    d  } } d } |  |  } | sd d
 d t j |  d d t j   k sjt j |   ryt j |   n d d t j |  i } t t j |    d  } } d } |  |  } | } | sGd d d t j |  d d t j   k s
t j |   rt j |   n d d t j |  i } t t j |    d  } } } d } |  |  } | } | sd d d t j |  d d t j   k st j |   rt j |   n d d t j |  i } t t j |    d  } } } d  S)Nr   )isimportabler   z0assert not %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}r   r   r  r   r   z,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}x1Zx_1_Z_1zx-1zx:1)	Zpy._path.localr  r   r   r   r   r   r   r   )r  r   r   r   r   r?   r	   r	   r
   test_isimportable  sh        b     b  
   b  
   b  
   b  
   b  
    b      b  r  c             C   s  t  j   } |  j d |  t j } | j } | j } |   } t j } | j } | |  } | | k }	 |	 rt j d f |	 f d f | | f  d t j	 |  d d t
 j   k p t j t  r t j	 t  n d d t j	 |  d t j	 |  d	 t j	 |  d
 t j	 |  d t j	 |  d d t
 j   k pFt j t  rXt j	 t  n d d t j	 |  d d t
 j   k pt j |  rt j	 |  n d i
 }
 d d d |
 i } t t j |    d  } } } } }	 } } } d  S)Nr   r5   z%(py8)s
{%(py8)s = %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.path
}.local
}._gethomedir
}()
} == %(py17)s
{%(py17)s = %(py14)s
{%(py14)s = %(py12)s
{%(py12)s = %(py10)s.path
}.local
}(%(py15)s)
}r   r   rG   rC   r   rD   r   ra   r   r   r`   r*   r   zassert %(py19)srg  )r   r   r   rG   r*   r   _gethomedirr   r;   r   r   r   r   r   r   )r   r*   r   r   r   r    rK   rL   r  r!   rq   rj  r	   r	   r
   test_homedir_from_HOME  s     	 	 	 	 	 	     7   r  c             C   s   |  j  d d d |  j  d d d t 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
 |  i } d d | i } t t j |    d  } } d  S)Nr   raisingF	HOMEDRIVEr   %(py0)s is %(py3)sr   homedirr   r   assert %(py5)sr   )r   )r  r  )delenvrG   r*   r   r  r   r;   r   r   r   r   r   r   )r   r  r   r   r   r   r	   r	   r
   test_homedir_not_exists$  s       j   r  c       	      C   s  |  j  } | |   } | s d d d t j |  d d t j   k sU t j |   rd t j |   n d d t j |  d d t j   k s t j |   r t j |   n d i } t t j |    d  } } |  j d  } | j  } | |  } | sd d d t j |  d d	 t j   k s6t j |  rEt j |  n d	 d t j |  d d	 t j   k s{t j |  rt j |  n d	 i } t t j |    d  } } | j	   j
    | j  } | j } | |  } | sd d
 d t j |  d t j |  d d	 t j   k s3t j |  rBt j |  n d	 d t j |  d d	 t j   k sxt j |  rt j |  n d	 i } t t j |    d  } } } Wd  QRXt j d k r| j t |  j    } | j t |  j    } | j  } | |  } | sd d d t j |  d d t j   k sUt j |  rdt j |  n d d t j |  d d t j   k st j |  rt j |  n d i } t t j |    d  } } d  S)Nr   zJassert %(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.samefile
}(%(py3)s)
}r   r   r   r   r   rW   r9   zhassert %(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.samefile
}(%(py5)s
{%(py5)s = %(py3)s.basename
})
}r   r2  rH  rI  )samefiler   r   r   r   r   r   r   rw   rJ   r   r<   r6  r7  	__class__r   lowerupper)	r   r   r   r   r9   r   rz   rH  rI  r	   r	   r
   test_samefile*  s<    	     
	     
	 	     	     r#  c             C   s   |  j  d  |  j d  d } | j } d } | | k } | s t j d | f d | | f  d t j |  d t j |  d t j |  i } d d
 | i } t t j |    d  } } } } d  S)NrW   r   r5   0%(py3)s
{%(py3)s = %(py1)s.basename
} == %(py6)sr   r   r   r   assert %(py8)sr   )r5   )r$  r%  )rw   r  r<   r   r;   r   r   r   )r   r   r   r   r   r   r=   r	   r	   r
   test_listdir_single_arg5  s     	    R   r&  c          
   C   s  t  j d |   } |  j } |   } | g } | | k } | s t j d | f d | | f  d t j |  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  } } } } d  S)Nr  r5   F%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.listdir
}()
} == %(py7)sr   r   r   r   r   r   assert %(py9)sr]   )r5   )r'  r(  )r   r
  r  r   r;   r   r   r   r   r   r   )r   Zdtmpr   r   r   r   rz   r   r	   r	   r
   test_mkdtemp_rootdir9  s    	 	 	      r)  c               @   sj   e  Z d  Z e Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z	 d d   Z
 d d   Z d S)TestWINLocalPathc             C   s*   t  j j t d  t  j j t d  d  S)Nzpath1.stat().ownerzpath1.stat().group)rG   ri   rj   r  )r)   r   r	   r	   r
    test_owner_group_not_implemented@  s    z1TestWINLocalPath.test_owner_group_not_implementedc       	      C   s  t  j j d |  | j   j } | j | d k r: d p= d  zCt | j   j  t |  | j } |   } | j } | | k } | sqt j d | f d | | f  d t j	 |  d t j	 |  d d	 t
 j   k s t j |  r t j	 |  n d	 d
 d t
 j   k s$t j |  r3t j	 |  n d d t j	 |  i } d d | i } t t j |    d  } } } } Wd  | j |  | j } |   } | j } | | k } | st j d | f d | | f  d t j	 |  d t j	 |  d d	 t
 j   k s!t j |  r0t j	 |  n d	 d
 d t
 j   k sWt j |  rft j	 |  n d d t j	 |  i } d d | i } t t j |    d  } } } } Xd  S)Nzpath1 isr   rt   r   ]%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.stat
}()
}.mode
} != %(py8)sr   r   r   r   r   rY   r   r   assert %(py10)sr   r5   ]%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.stat
}()
}.mode
} == %(py8)s)r   )r,  r-  )r5   )r.  r-  )rG   rb   print_statrY   rx   printr   r;   r   r   r   r   r   r   )	r)   r   rY   r   r   r   r    r=   r"   r	   r	   r
   test_chmod_simple_intD  s2    
	 	 	      	 	 	      z&TestWINLocalPath.test_chmod_simple_intc             C   s  | j  d  } | j  d  } | | k } | s t j d | f d | | f  d d t j   k sr t j |  r t j |  n d d d t j   k s t j |  r t j |  n d i } d d
 | i } t t j |    d  } | | k } | st j d | f d | | f  d d t j   k s@t j |  rOt j |  n d d d t j   k svt j |  rt j |  n d i } d d
 | i } t t j |    d  } d  S)Na_pathA_pathr5   %(py0)s == %(py2)sr   t1r   r   assert %(py4)sr   t2)r5   )r5  r7  )r5   )r5  r7  )	r   r   r;   r   r   r   r   r   r   )r)   r   r6  r8  r   r>   r?   r	   r	   r
   $test_path_comparison_lowercase_mixedQ  s              z5TestWINLocalPath.test_path_comparison_lowercase_mixedc       
      C   sG  | j  d d  } | j  d  } | j } | |  } d } | | k } | s1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 d t j   k s t j |  rt j |  n d i } d d | i }	 t t j	 |	    d  } } } } d  S)Nr3  ZfiLer4  r5   K%(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.relto
}(%(py3)s)
} == %(py8)sr   r   r6  r   r   r   r8  r   assert %(py10)sr   )r5   )r:  r;  )
r   r  r   r;   r   r   r   r   r   r   )
r)   r   r6  r8  r   r   r    r   r=   r"   r	   r	   r
   test_relto_with_mixed_caseW  s    	        z+TestWINLocalPath.test_relto_with_mixed_casec       	      C   s  | j  d  } t |  } d } | | } | | k } | sGt j d | f d | | f  d t j |  d t j |  d d t j   k s t j |  r t j |  n d d	 d
 t j   k s t j t  r t j t  n d
 d d t j   k s	t j |  rt j |  n d i } d d | i } t t j	 |    d  } } } } | j  d  } t |  } d } | | } | | k } | st j d | f d | | f  d t j |  d t j |  d d t j   k st j |  rt j |  n d d	 d
 t j   k s,t j t  r;t j t  n d
 d d t j   k sbt j |  rqt j |  n d i } d d | i } t t j	 |    d  } } } } | j  d  } t |  } d } | | } | | k } | st j d | f d | | f  d t j |  d t j |  d d t j   k sOt j |  r^t j |  n d d	 d
 t j   k st j t  rt j t  n d
 d d t j   k st j |  rt j |  n d i } d d | i } t t j	 |    d  } } } } d  S)Nr3  z\a_pathr5   <%(py0)s == (%(py5)s
{%(py5)s = %(py2)s(%(py3)s)
} + %(py7)s)r   r   r   r6  r   r   r   r   r   assert %(py10)sr   za_path/z
dir/a_pathz\dir\a_path)r5   )r=  r>  )r5   )r=  r>  )r5   )r=  r>  )
r   r   r   r;   r   r   r   r   r   r   )	r)   r   r6  r   r   r   r   r=   r"   r	   r	   r
   test_allow_unix_style_paths\  s<      
        
        
      z,TestWINLocalPath.test_allow_unix_style_pathsc       	      C   s  t  j j j d  } | j d d d d  } | j    t  j j j | j |   } | j } d } | d |  } | 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  } } } Wd  QRXd  S)NrW  dirnamer   r<   rt   r   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(file=%(py4)s)
}r   r   r   r   r   )rG   r*   r   ra  r  r   r  r   r   r   r   r   r   r   r   )	r)   r   rW  rootr   r   r   r   r   r	   r	   r
   test_sysfind_in_currentdird  s    	    q  z+TestWINLocalPath.test_sysfind_in_currentdirc             C   sW  d d  l  } | j d d  } | j } | j } | j } d } | |  } | |  }	 |	 sFd d d t j |  d t j |  d	 t j |  d
 d t j   k s t j |  r t j |  n 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 t |  d d g  } | j } | |  } | sId d d t j |  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 i } t	 t j
 |    d  } } d  S)Nr   r:  r<  rQ  r   zassert %(py13)s
{%(py13)s = %(py2)s
{%(py2)s = %(py0)s.fnmatch
}(%(py11)s
{%(py11)s = %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.sep
}.join
}(%(py9)s)
})
}r   r   r[   r   	posixpathr\   r]   r   r   rR  zIassert %(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.fnmatch
}(%(py3)s)
}rS  )rC  r   rT  rU  r   r   r   r   r   r   r   r   )r)   r   rC  r<  r   r   r   r   rm   rn   r  rS  r   r	   r	   r
   0test_fnmatch_file_abspath_posix_pattern_on_win32k  s&    	 	 	       !	     zATestWINLocalPath.test_fnmatch_file_abspath_posix_pattern_on_win32N)r-   r.   r/   rz  r{  r+  r2  r9  r<  r?  rB  rD  r	   r	   r	   r
   r*  =  s   r*  c               @   s{  e  Z d  Z e 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' d(   Z e j j d) d* d+ d,  d- d.    Z d/ d0   Z d1 d2   Z e d3 d4    Z  e d5 d6    Z! e d7 d8    Z" d9 S):TestPOSIXLocalPathc             C   s  | j  d  } | j  d  } | j d  | j   j } | j |  | j } |   } | j } d } | | }	 | |	 k }
 |
 svt j d |
 f d | |	 f  d t j |  d t j |  d	 d
 t j	   k s t j
 |  r t j |  n d
 d t j |  d d t j	   k s)t j
 |  r8t j |  n d d t j |  i } d d | i } t t j |    d  } } } }
 } }	 d  S)Nri   r   Hellort   r5   k%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.stat
}()
}.nlink
} == (%(py8)s + %(py10)s)r   r   r   nlinkr   r   filepathr   r   assert %(py13)sr\   )r5   )rG  rJ  )r   rf   r0  rH  mklinktor   r;   r   r   r   r   r   r   )r)   r   linkpathrI  rH  r   r   r   r!   rK   r    r   r  r	   r	   r
   test_hardlinkw  s     	 	 	  
      z TestPOSIXLocalPath.test_hardlinkc       
      C   s  | j  d  } | j d  | j  d  } | j |  | j } |   } t |  } | | 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	 d
 t j	   k s t j
 t  r t j t  n d
 d t j |  d d t j	   k s4t j
 |  rCt j |  n d d t j |  i } d d | i }	 t t j |	    d  } } } } d  S)Nr   rF  ri   r5   e%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.readlink
}()
} == %(py9)s
{%(py9)s = %(py6)s(%(py7)s)
}r   r   rI  r   r   r]   r   rL  r   r   assert %(py11)sr[   )r5   )rN  rO  )r   rf   mksymlinktoreadlinkr   r   r;   r   r   r   r   r   r   )
r)   r   rI  rL  r   r   r   r   r   r   r	   r	   r
   test_symlink_are_identical  s    	 	       z-TestPOSIXLocalPath.test_symlink_are_identicalc             C   so  | j  d  } | j  d  } | j d  | j |  | j } d } | d |  } | 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 } d } d } | d | d |  } | }	 |	 sd d d t j |  d t j |  d d	 t j   k spt j |  rt j |  n d	 d t j |  d
 t j |  i }
 t	 t j
 |
    d  } } } } }	 | j } |   } | sad d d t j |  d d	 t j   k s$t j |  r3t j |  n d	 d
 t j |  i } t	 t j
 |    d  } } d  S)Nri   r   r   rt   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(file=%(py4)s)
}r   r   r   rL  r   r   linkz^assert not %(py8)s
{%(py8)s = %(py2)s
{%(py2)s = %(py0)s.check
}(link=%(py4)s, file=%(py6)s)
}r   zAassert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.islink
}()
})r   rf   rP  r   r   r   r   r   r   r   r   islink)r)   r   rL  rI  r   r   r   r   r    r!   r   r?   r	   r	   r
   test_symlink_isfile  s4    	    q  	        	 	  b  z&TestPOSIXLocalPath.test_symlink_isfilec             C   si  | j  d  } | j  d  } | j d  | j | d d | j } |   } d } | | k } | st j d | f d | | f  d t j |  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 }
 |
   } | | k } | sOt j d | f d | | f  d t j |  d t j |  d t j |
  d d t j   k st j	 |  rt j |  n d d
 d t j   k st j	 |  rt j |  n d d t j |  i } d d | i } t
 t j |    d  } } } }
 } d  S)Nri   r   rF  absoluteFr5   G%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.readlink
}()
} == %(py7)sr   r   r   rL  r   r   assert %(py9)sr]   v%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read
}()
} == %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s.read
}()
}r   r   r   rI  assert %(py12)srC   )r5   )rW  rX  )r5   )rY  rZ  )r   rf   rP  rQ  r   r;   r   r   r   r   r   r   r   )r)   r   rL  rI  r   r   r   r   rz   r   r    r!   r"   r   r	   r	   r
   test_symlink_relative  s.    	 	       	 	 	 	      z(TestPOSIXLocalPath.test_symlink_relativec       	   
   C   s  | j  d  } | j } d } | d |  } | } | 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 } d } | d |  } | s|d d d t j |  d t j |  d d	 t j   k s?t j |  rNt j |  n d	 d
 t j |  i } t t j |    d  } } } d  S)NZtestnotexistingrt   rS  r   zPassert not %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(link=%(py4)s)
}r   r   r   rL  r   r   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(link=%(py4)s)
})	r   r   r   r   r   r   r   r   r   )	r)   r   rL  r   r   r   r    rz   r   r	   r	   r
   test_symlink_not_existing  s     	     q  	    q  z,TestPOSIXLocalPath.test_symlink_not_existingc       	      C   s   | j  d  j t j j d   } | d } t |  d } | | k } | s t j d | f d | | f  d t j |  d t j |  i } d d | i } t	 t j
 |    d  } } } d  S)Nr   /r   rt   r5   %(py1)s == %(py4)sr   r   r   assert %(py6)sr   )r5   )r^  r_  )r   r  rG   r*   r   r   r   r;   r   r   r   )	r)   r   r   r  r   r   r   r?   r   r	   r	   r
   test_relto_with_root  s    $
    C   z'TestPOSIXLocalPath.test_relto_with_rootc       	   
   C   sA  | j  d  } | j |  | j d  d d    } t |  } | g } | | 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 t  r t j	 t  n d
 d t j	 |  i } d d | i } t
 t j |    d  } } } d  S)Nri   c             S   s   |  j  d d  S)NrS  r   )r   )r   r	   r	   r
   r     s    zATestPOSIXLocalPath.test_visit_recursive_symlink.<locals>.<lambda>r5   0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   visitorr   r   rF  r   r   assert %(py8)sr   )r5   )ra  rc  )r   rP  rG  rF  r   r;   r   r   r   r   r   r   )	r)   r   rL  rb  r   r   r   r   r=   r	   r	   r
   test_visit_recursive_symlink  s     	      z/TestPOSIXLocalPath.test_visit_recursive_symlinkc       
      C   s  | j  d  } | j |  | j } d } | d |  } | 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 } d } d } | d | d |  } | } | sd d d t j |  d t j |  d d	 t j   k sTt j |  rct j |  n d	 d t j |  d
 t j |  i }	 t t j	 |	    d  } } } } } d  S)Nri   rt   r}   r   zKassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(dir=%(py4)s)
}r   r   r   rL  r   r   rS  z]assert not %(py8)s
{%(py8)s = %(py2)s
{%(py2)s = %(py0)s.check
}(link=%(py4)s, dir=%(py6)s)
}r   )
r   rP  r   r   r   r   r   r   r   r   )
r)   r   rL  r   r   r   r   r    r!   r   r	   r	   r
   test_symlink_isdir  s$    	    q  	        z%TestPOSIXLocalPath.test_symlink_isdirc          
   C   s  | j  d  } | j |  | j } d } | d |  } | 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 } |   } | } | std d d t j |  d d	 t j   k s7t j |  rFt j |  n d	 d
 t j |  i } t t j	 |    d  } } } d  S)Nri   rt   rS  r   zLassert %(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.check
}(link=%(py4)s)
}r   r   r   rL  r   zDassert not %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.check
}()
})r   rP  r   r   r   r   r   r   r   r   ry   )r)   r   rL  r   r   r   r   r   r	   r	   r
   test_symlink_remove  s"    	    q  
	 	   b  z&TestPOSIXLocalPath.test_symlink_removec       
      C   s  | j  d  } | j  d  } | j d  | j |  | j   } | j } 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 |  i } d d | i }	 t t j |	    d  } } } d  S)Nri   r   r   r5   0%(py2)s
{%(py2)s = %(py0)s.basename
} == %(py5)sr   r   realpathr   assert %(py7)sr   )r5   )rg  ri  )r   rf   rP  rh  r<   r   r;   r   r   r   r   r   r   )
r)   r   rL  rI  rh  r   r   r   r   rz   r	   r	   r
   test_realpath_file  s    	    y   z%TestPOSIXLocalPath.test_realpath_filec             C   s  d d l  m } d d l m } | j   } | j } | | k } | st j d | f d | | f  d d t j	   k s t j
 |  r t j |  n d 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 } | j } |
 | 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
 d	 t j	   k st j
 |  rt j |  n d	 i } d d | i }	 t t j |	    d  } } | j } | | 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
 d	 t j	   k st j
 |  rt j |  n d	 i } d d | i }	 t t j |	    d  } } | j } | | 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
 d	 t j	   k st j
 |  rt j |  n d	 i } d! d | i }	 t t j |	    d  } } | j } | | k } | st j d" | f d# | | f  d t j |  d d t j	   k srt j
 |  rt j |  n d d
 d	 t j	   k st j
 |  rt j |  n d	 i } d$ d | i }	 t t j |	    d  } } d  S)%Nr   )getpwuid)getgrgidr5   ,%(py2)s
{%(py2)s = %(py0)s.path
} == %(py4)sr   r   r   r0  r   r   assert %(py6)sr   +%(py0)s == %(py4)s
{%(py4)s = %(py2)s.uid
}uid-%(py0)s == %(py4)s
{%(py4)s = %(py2)s.owner
}owner+%(py0)s == %(py4)s
{%(py4)s = %(py2)s.gid
}gid-%(py0)s == %(py4)s
{%(py4)s = %(py2)s.group
}group)r5   )rm  rn  )r5   )ro  rn  )r5   )rq  rn  )r5   )rs  rn  )r5   )ru  rn  )pwdrk  grprl  r0  r*   r   r;   r   r   r   r   r   r   rp  rt  rr  rv  )r)   r   r   rk  rl  r0  r   r   r?   r   rp  rt  rr  rv  r	   r	   r
   
test_owner  sT    	      
			      
	      
	      
	      zTestPOSIXLocalPath.test_ownerc             C   s  | j  d  } | j   } | j   } | j } |   } | s d d d t j |  d d t j   k sy t j |  r t j |  n d d t j |  i } t t j	 |    d  } } | j
 } |   } | sOd d 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 } |   } | }	 |	 sd d
 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 } |   } | }	 |	 sd d
 d t j |  d d	 t j   k sVt j |  ret j |  n d	 d t j |  i }
 t t j	 |
    d  } } }	 d  S)Nr   r   zAassert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.isfile
}()
}r   r   stat1r   z@assert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.isdir
}()
}stat2zEassert not %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.islink
}()
})rw   r0  isfiler   r   r   r   r   r   r   isdirrT  )r)   r   r   r   rz  r{  r   r   r?   r   r   r	   r	   r
   test_stat_helpers  s:    	 	  b  
	 	  b  
	 	   b  	 	   b  z$TestPOSIXLocalPath.test_stat_helpersc                s   | j  d    t j t j j   f d d      j d d  } 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 |  i } d d | i } t t j |    d  } } d  S)Nr   c                  s
     j    S)N)r0  r	   )r   r	   r
   r     s    z:TestPOSIXLocalPath.test_stat_non_raising.<locals>.<lambda>r  Fr   %(py0)s is %(py3)sr   r  r   r   assert %(py5)sr   )r   )r  r  )r   r   rj   rG   r   r   r0  r   r;   r   r   r   r   r   r   )r)   r   r  r   r   r   r   r	   )r   r
   test_stat_non_raising  s    "   j   z(TestPOSIXLocalPath.test_stat_non_raisingc             C   s  d d  l  } | j d  } | j    } | j   } | j   | j t  | j   } | j t  | j    | } | | } | | k }	 |	 s{t j d |	 f d | | f  d d t j	   k s t j
 |  r t j |  n d d d t j	   k st j
 |  rt j |  n d d	 d
 t j	   k s=t j
 |  rLt j |  n d
 i }
 d d |
 i } t t j |    d  } }	 d  S)Nr   r   <=(%(py0)s - %(py1)s) <= %(py4)sr   atime1r   durationr   atime2r   assert %(py6)sr   )r  )r  r  )r   rw   atimer   sleepATIME_RESOLUTIONr   r;   r   r   r   r   r   r   )r)   r   r   r*   nowr  r  r  r   r   r?   r   r	   r	   r
   
test_atime  s     

      zTestPOSIXLocalPath.test_atimec       	      C   s  | j  d  } | j  d  } | j } | |  } | | 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 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 i } d d | i } t t j	 |    d  } } } | 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 |  d d	 t j   k sPt j |  r_t j |  n d	 i } d d | i } t t j	 |    d  } } } d  S)N	somethingZ
otherthingr5   L%(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.common
}(%(py3)s)
} == %(py7)sr   r   r   r   rH  r   r   rI  r   assert %(py9)sr]   )r5   )r  r  )r5   )r  r  )
r   r   r   r;   r   r   r   r   r   r   )	r)   r   rH  rI  r   r   r   rz   r   r	   r	   r
   test_commondir  s$    	       	       z!TestPOSIXLocalPath.test_commondirc       
      C   sN  | j  d  } t j j | j d  } | j } | |  } d } | | k } | s8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 d t	 j
   k s t j |  r	t j |  n d i } d d | i }	 t t j |	    d  } } } } d  S)Nr  Zblablar]  r5   L%(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.common
}(%(py3)s)
} == %(py8)sr   r   rH  r   r   r   rI  r   assert %(py10)sr   )r5   )r  r  )r   rG   r*   r   rU  r   r   r;   r   r   r   r   r   r   )
r)   r   rH  rI  r   r   r    r   r=   r"   r	   r	   r
   test_commondir_nocommon  s    	        z*TestPOSIXLocalPath.test_commondir_nocommonc             C   s  | j    d } t |  } t |  } d } | | k } | sYt j d | f d | | f  d t j |  d d t j   k s t j t  r t j t  n d d t j |  d	 t j |  d
 d t j   k s t j t  r t j t  n d d d t j   k st j |  r*t j |  n d i } d d | i } t	 t j
 |    d  } } } } | j }	 d }
 |	 |
  } t |  } d } | | k } | st j d | f d | | f  d t j |  d t j |
  d t j |  d t j |	  d d t j   k s(t j |  r7t j |  n d d	 t j |  d
 d t j   k smt j t  r|t j t  n d i } d d | i } t	 t j
 |    d  }	 }
 } } } } d  S) Nr   rt   r5   N%(py6)s
{%(py6)s = %(py0)s(%(py4)s
{%(py4)s = %(py1)s(%(py2)s)
})
} == %(py9)sr   r   r   r   r]   r   r@  r   rA  r   assert %(py11)sr[   r:  z//ai%(py9)s
{%(py9)s = %(py0)s(%(py7)s
{%(py7)s = %(py3)s
{%(py3)s = %(py1)s.join
}(%(py5)s)
})
} == %(py12)sr   r   rC   r   assert %(py14)srD   )r5   )r  r  )r5   )r  r  )partsr   r@  r   r;   r   r   r   r   r   r   r   )r)   r   rA  r   r   r   r    r   r   r   r   r   rK   rm   r   rM   r	   r	   r
   test_join_to_root  s*            	          z$TestPOSIXLocalPath.test_join_to_rootc             C   so  | j  d  } t |  } t |  } | | k } | rt j d f | f d f | | f  d d t j   k p t j t  r t j t  n d d t j |  d t j |  d d	 t j   k p t j |  r t j |  n d	 d
 d t j   k p	t j |  rt j |  n d d d t j   k p?t j t  rQt j t  n d i } d d d | i } t t j	 |    d  } } } | | k } | ret j d f | f d f | | f  d d	 t j   k pt j |  rt j |  n d	 d d t j   k p t j |  r2t j |  n d i }	 d d d |	 i }
 t t j	 |
    d  } d  S)Nr]  r5   zN%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py8)s
{%(py8)s = %(py5)s(%(py6)s)
}r   r   r   r   r   r   r   nrootr   r   zassert %(py10)sr   z%(py0)s == %(py2)sr   zassert %(py4)sr   )
r   r   r   r;   r   r   r   r   r   r   )r)   r   r  r   r    r   r=   r"   r   r>   r?   r	   r	   r
   "test_join_root_to_root_with_no_abs  s          "        z5TestPOSIXLocalPath.test_join_root_to_root_with_no_absc       	      C   s  | j    j } | j t | d   z&| j  } |   } | j } | | k } | s9t j d | f d | | f  d t j |  d t j |  d d t j   k s t j	 |  r t j |  n d d d	 t j   k s t j	 |  r t j |  n d	 d
 t j |  i } d d | i } t
 t j |    d  } } } } Wd  | j |  | j  } |   } | j } | | k } | slt j d | f d | | f  d t j |  d t j |  d d t j   k st j	 |  rt j |  n d d d	 t j   k st j	 |  r.t j |  n d	 d
 t j |  i } d d | i } t
 t j |    d  } } } } Xd  S)NrB  r   ]%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.stat
}()
}.mode
} != %(py8)sr   r   r   r   r   rY   r   r   assert %(py10)sr   r5   ]%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.stat
}()
}.mode
} == %(py8)s)r   )r  r  )r5   )r  r  )r0  rY   rx   r   r   r;   r   r   r   r   r   r   )	r)   r   rY   r   r   r   r    r=   r"   r	   r	   r
   r2    s,    	 	 	      	 	 	      z(TestPOSIXLocalPath.test_chmod_simple_intc          !   C   s  d d   } i  } x- | j  d |  D] } | j   j | | <q% W| j t d d  d | z:x3| j  d |  D]} | j } |   } | j } d } d }	 t | |	  }
 | |
 @} d } d } t | |  } | | k } | ret j d f | f d f | | f  d	 t j |  d
 d t j	   k p<t j
 t  rNt j t  n d d t j |  d t j |
  d t j |  d t j |  d t j |	  d t j |  d t j |  d t j |  d d t j	   k pt j
 |  rt j |  n d d d t j	   k p t j
 t  r2t j t  n d i } d d d | i } t t j |    d  } } } } }	 }
 } } } } } qt WWd  x' | j   D] \ } } | j |  qWXd  S)Nc             S   s   |  j  d d d d  S)Ndotfiler   rS  )r   )r   r	   r	   r
   r     s    z7TestPOSIXLocalPath.test_chmod_rec_int.<locals>.<lambda>r	  Z772r   Z777r5   z(%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.stat
}()
}.mode
} & %(py13)s
{%(py13)s = %(py7)s(%(py9)s, %(py11)s)
}) == %(py22)s
{%(py22)s = %(py16)s(%(py18)s, %(py20)s)
}r   r   r   Zpy22r\   rI   r   r[   rH   r   r]   r   r   rE   r   zassert %(py24)sZpy24)rG  r0  rY   rx   r   r   r;   r   r   r   r   r   r   items)r)   r   Z	recfilterZoldmodesr   r   r   r   r   rm   rn   ro   rP   @py_assert19@py_assert21rO   Z@py_format23Z@py_format25r  r	   r	   r
   test_chmod_rec_int
  s4    	 	 	    
       U   6z%TestPOSIXLocalPath.test_chmod_rec_intstrictFr1  zunicode issuec             C   s*  d } | j  d |  } | j   } | j   j } | d A} | j |  | j d  } | j | d d | j } | j }	 | |	  }
 |
 j } |   } | j } | | k } | rt j	 d f | f d f | | f  d	 t j
 |
  d
 t j
 |	  d t j
 |  d d t j   k p*t j |  r<t j
 |  n d d t j
 |  d t j
 |  d d t j   k p~t j |  rt j
 |  n d d t j
 |  d d t j   k pt j |  rt j
 |  n d i	 } d d d | i } t t j |    d  } }	 }
 } } } } d  S)Nu   something-â.txtr:  rt   r<  rY   Tr5   z%(py13)s
{%(py13)s = %(py11)s
{%(py11)s = %(py9)s
{%(py9)s = %(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py5)s
{%(py5)s = %(py3)s.basename
})
}.stat
}()
}.mode
} == %(py15)sr   r   r[   r   r   r\   r]   r   r   r`   newmoder   zassert %(py17)sra   )rw   rJ   r0  rY   rx   r   copyr<   r   r;   r   r   r   r   r   r   )r)   r   Z
unicode_fnr   r:  Zoldmoder  r<  r   r   r   r   rm   rn   ro   rp   rq   r	   r	   r
   test_copy_archiving  s*    
	 	  	 	 	    (   z&TestPOSIXLocalPath.test_copy_archivingc             C   s  | j  d  } | j d  } t j t  | j | d d | j   } | j   } | j } | j } | | k } | rYt j	 d f | f d f | | f  d d t
 j   k p t j |  r t j |  n d d	 t j |  d
 d t
 j   k pt j |  rt j |  n d d t j |  i }	 d d d |	 i }
 t t j |
    d  } } } | j } |   } | j } |   } | | } | t k  } | rt j	 d f | f d f | t f  d t j |  d t j |  d d t
 j   k pt j |  rt j |  n d d d t
 j   k pAt j t  rSt j t  n d d t j |  d
 d t
 j   k pt j |  rt j |  n d d t j |  i } d d d | i } t t j |    d  } } } } } } | j } |   } | j } |   } | | } | t k  } | rgt j	 d f | f d f | t f  d t j |  d t j |  d d t
 j   k pt j |  rt j |  n d d d t
 j   k pt j t  rt j t  n d d t j |  d
 d t
 j   k pt j |  r%t j |  n d d t j |  i } d d d | i } t t j |    d  } } } } } } d  S)Nsrcdstr0  Tr5   zF%(py2)s
{%(py2)s = %(py0)s.mode
} == %(py6)s
{%(py6)s = %(py4)s.mode
}r   newstatr   r   oldstatr   r   zassert %(py8)sr   r   z(%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.atime
}()
} - %(py9)s
{%(py9)s = %(py7)s
{%(py7)s = %(py5)s.atime
}()
}) < %(py12)sr   r   rC   r  r]   zassert %(py14)srD   z(%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.mtime
}()
} - %(py9)s
{%(py9)s = %(py7)s
{%(py7)s = %(py5)s.mtime
}()
}) < %(py12)s)rw   r   r   r  r  r  r0  rY   r   r;   r   r   r   r   r   r   r  r   )r)   r   r  r  r  r  r   r   r   r   r=   r   r   rm   rK   r   rM   r	   r	   r
   test_copy_stat_file$  sL    	 	      	 	 	 	 
    
   	 	 	 	 
    
   z&TestPOSIXLocalPath.test_copy_stat_filec             C   sS  d d d g } | j  d  } x* | D]" } | j  |  j | d d q% W| j  d  } t j t  | j | d d x| D]} | j  |  j   } | j  |  j   } | j } | j }	 | |	 }
 |
 t k  } | st j	 d | f d |
 t f  d t j
 |	  d d t j   k s0t j |  r?t j
 |  n d d d t j   k sft j t  rut j
 t  n d d t j
 |  d d t j   k st j |  rt j
 |  n d i } d d | i } t t j |    d  } }	 }
 } | j } | j }	 | |	 }
 |
 t k  } | s3t j	 d | f d  |
 t f  d t j
 |	  d d t j   k szt j |  rt j
 |  n d d d t j   k st j t  rt j
 t  n d d t j
 |  d d t j   k st j |  rt j
 |  n d i } d! d | i } t t j |    d  } }	 }
 } | 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  } } } q Wd  S)%Nr:  r<  cr  rw   Tr  r0  r   S(%(py2)s
{%(py2)s = %(py0)s.atime
} - %(py5)s
{%(py5)s = %(py3)s.atime
}) < %(py8)sr   r   r  r   r  r   r   r  r   assert %(py10)sr   S(%(py2)s
{%(py2)s = %(py0)s.mtime
} - %(py5)s
{%(py5)s = %(py3)s.mtime
}) < %(py8)sr5   F%(py2)s
{%(py2)s = %(py0)s.mode
} == %(py6)s
{%(py6)s = %(py4)s.mode
}r   r   assert %(py8)s)r   )r  r  )r   )r  r  )r5   )r  r  )r   rf   r   r  r  r  r0  r  r   r;   r   r   r   r   r   r   r   rY   )r)   r   Z
test_filesr  r   r  r  r  r   r   r   r    r=   r"   r   r   r   r	   r	   r
   test_copy_stat_dir0  sH     	 	 
      	 	 
      	 	      z%TestPOSIXLocalPath.test_copy_stat_dirc             C   s2   | j    j } | j    j } | j | |  d  S)N)r0  rr  rv  chown)r)   r   rr  rv  r	   r	   r
   test_chown_identity@  s    z&TestPOSIXLocalPath.test_chown_identityc             C   sl   | j    j } | j    j } | j d  } | j d  z | j | | d d Wd  | j d d  Xd  S)NrW   Zqlwkejqwlekr	  rt   r   )r0  rr  rv  r   rP  r  ry   )r)   r   rr  rv  r   r	   r	   r
   test_chown_dangling_linkF  s    z+TestPOSIXLocalPath.test_chown_dangling_linkc             C   s2   | j    j } | j    j } | j | |  d  S)N)r0  rr  rv  r  )r)   r   rr  rv  r	   r	   r
   test_chown_identity_rec_mayfailQ  s    z2TestPOSIXLocalPath.test_chown_identity_rec_mayfailN)#r-   r.   r/   rm  r{  rM  rR  rU  r[  r\  r`  rd  re  rf  rj  ry  r~  r  r  r  r  r  r  r2  r  r   rn  ro  r  r  r  failsonjythonr  r  r  r	   r	   r	   r
   rE  t  s6   			'rE  c               @   s   e  Z d  Z e j j e j d k o0 d e j	 k d d g Z
 e j j e j d k d d Z e d d    Z e d	 d
    Z e j j d d  d d    Z d S)TestUnicodePy2Py3r>  r   LANGr1  zcannot run test without localez3unresolved encoding issues for pathnames on python3c             C   sm  t  j j | j  } d } | 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 |  d
 d t j	   k st j
 |  r,t j |  n d i }	 d d |	 i }
 t t j |
    d  } } } d  S)Nu   hällor5   J%(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s.join
}(%(py3)s)
} == %(py7)sr   r  r   r   r   r   r   partr   assert %(py9)sr]   )r5   )r  r  )rG   r*   r   r.  rw   r   r   r;   r   r   r   r   r   r   )r)   r   r   r   r  r  r   r   r   rz   r   r	   r	   r
   test_join_ensuref  s    	       z"TestUnicodePy2Py3.test_join_ensurec       	      C   s   t  j j | j  } d } | j |  } | j |  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 i } d d
 | i } t t j |    d  } } d  S)Nu   hällor   r5   %(py1)s == %(py3)sr   r   r  r   assert %(py5)sr   )r5   )r  r  )rG   r*   r   r.  rw   r  r   r;   r   r   r   r   r   r   )	r)   r   r   r  r  r   r   r   r   r	   r	   r
   test_listdirm  s       j   zTestUnicodePy2Py3.test_listdirz/changing read/write might break existing usagesc             C   s  | j  d  } t j j d d  } | j |  | j } |   } | | k } | r4t j d f | f d f | | f  d t j |  d d t	 j
   k p t j |  r t j |  n d d	 d
 t	 j
   k p t j |  r t j |  n d
 d t j |  i } d d d | i } t t j |    d  } } } | j | j t j     | j } |   } | j }	 t j }
 |
   } |	 |  } | | k } | rt j d f | f d f | | f  d t j |  d t j |
  d t j |	  d t j |  d d t	 j
   k p+t j |  r=t j |  n d d d t	 j
   k pat j t  rst j t  n d d	 d
 t	 j
   k pt j |  rt j |  n d
 d t j |  d t j |  i	 } d d d | i } t t j |    d  } } } }	 }
 } } d  S)NrW   u   hälloutf8r5   zC%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read
}()
} == %(py6)sr   r   r  r   r   r   r   zassert %(py8)sr   z%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read
}()
} == %(py15)s
{%(py15)s = %(py8)s
{%(py8)s = %(py6)s.encode
}(%(py13)s
{%(py13)s = %(py11)s
{%(py11)s = %(py9)s.getdefaultencoding
}()
})
}r[   r\   r]   r6  r`   zassert %(py17)sra   )r   rG   rb   _totextrf   r   r   r;   r   r   r   r   r   r   re   r6  getdefaultencoding)r)   r   r   r  r   r   r   r   r=   r    rm   rn   ro   rp   rq   r	   r	   r
   test_read_writet  s2    	 	      	 	 	 	 	     (   z!TestUnicodePy2Py3.test_read_writeN)r>  r   )r>  r   )r-   r.   r/   r   rn  skipifr6  version_infor   environr{  ro  Z	bad_on_3xr  r  r  r	   r	   r	   r
   r  X  s   			r  c               @   s4   e  Z d  Z d d   Z d d   Z d d   Z d S)TestBinaryAndTextMethodsc             C   s  | j  d  } t j j d d  } | j d  } | j |  | j } |   } | | k } | s8t j d | f d | | f  d t j	 |  d d t
 j   k s t j |  r t j	 |  n d 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 d d  }
 |
 | k } | s t j d | f d |
 | f  d	 d t
 j   k st j |
  rt j	 |
  n d d d t
 j   k st j |  rt j	 |  n d i } d d | i } t t j |    d  } 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	 d t
 j   k st j t  rt j	 t  n d d t j	 |  i } t t j |    d  } } } d  S)NrW   u   hällor  r5   J%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read_binary
}()
} == %(py6)sr   r   	part_utf8r   r   r   r   assert %(py8)sr   encoding%(py0)s == %(py2)sr  r  assert %(py4)szfassert %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.builtin
}._istext
}(%(py5)s)
}r   r   rG   )r5   )r  r  )r5   )r  r  )r   rG   rb   r  re   write_binaryread_binaryr   r;   r   r   r   r   r   r   	read_text_istext)r)   r   r   r  r  r   r   r   r   r=   r  r>   r?   r   rz   r	   r	   r
   test_read_binwrite  s4    	 	           	 	     z+TestBinaryAndTextMethods.test_read_binwritec             C   su  | j  d  } t j j d d  } | j d  } | j | d d | j } |   } | | 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
 d t
 j   k s t j |  r t j	 |  n d d t j	 |  i } d d | i }	 t t j |	    d  } } } | j } d } | d |  } | | k }
 |
 s_t j d |
 f d | | f  d t j	 |  d t j	 |  d
 d t
 j   k st j |  rt j	 |  n d d d t
 j   k st j |  r!t j	 |  n d d t j	 |  i }	 d d |	 i } t t j |    d  } } } }
 d  S)NrW   u   hällor  r  r5   J%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read_binary
}()
} == %(py6)sr   r   r  r   r   r   r   assert %(py8)sr   X%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.read_text
}(encoding=%(py4)s)
} == %(py8)sr  assert %(py10)sr   )r5   )r  r  )r5   )r  r  )r   rG   rb   r  re   
write_textr  r   r;   r   r   r   r   r   r   r  )r)   r   r   r  r  r   r   r   r   r=   r    r"   r	   r	   r
   test_read_textwrite  s*    	 	      	        z,TestBinaryAndTextMethods.test_read_textwritec             C   s  | j  d  } t j j d d  } | j | d  | j d  } | | k } | rt j d f | f d f | | f  d d t j	   k p t j
 |  r t j |  n d d d t j	   k p t j
 |  r t j |  n d i } d	 d
 d | i } t t j |    d  } t |  } t |  }	 | |	 k }
 |
 rt j d f |
 f d f | |	 f  d d t j	   k pt j
 t  rt j t  n d d t j |	  d t j |  d d t j	   k pt j
 |  rt j |  n d d d t j	   k pt j
 |  r(t j |  n d d d t j	   k pLt j
 t  r^t j t  n d i } d	 d d | i } t t j |    d  } }
 }	 d  S)NrW   rX   r5   z%(py0)s == %(py2)sr   r  r   r  r   zassert %(py4)sr   zN%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py8)s
{%(py8)s = %(py5)s(%(py6)s)
}r   r  r   r   r   r   zassert %(py10)sr   )r   rG   rb   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
   test_default_encoding  s&              "   z.TestBinaryAndTextMethods.test_default_encodingN)r-   r.   r/   r  r  r  r	   r	   r	   r
   r  ~  s   
r  ),
__future__r   builtinsr   _pytest.assertion.rewrite	assertionrewriter   r   rG   r   r   r6  Zpy.pathr   r   ri   rn  ro  r  rq  r  rz  rm  r  r'   r2   ZCommonFSTestsr3   rr  r|  r  r  r  r  r  r  r#  r&  r)  r*  rE  r  r  r	   r	   r	   r
   <module>   sD     		
 Qh7&