o
    ACe                     @  s  U d dl mZ d dlZd dlZd dlmZmZ d dlmZm	Z	m
Z
 d dlZd dlZd dlmZ d dlmZ ejdYddZdZddZd[ddZd\ddZe
e	ej e	ej f Ze
ee	e f ZejejfejejfejejfgZded< ejded]ddZejejfejejfejefeejfgZ ded < ejde d^d"d#Z!ejdejejfejejfgejdg d$d_d%d&Z"d[d'd(Z#d[d)d*Z$ejdd+d,gd`d-d.Z%d[d/d0Z&ejdd1d2gd`d3d4Z'dad5d6Z(d[d7d8Z)d[d9d:Z*d\d;d<Z+G d=d> d>Z,G d?d@ d@Z-e-Z.dAedB< d\dCdDZ/d\dEdFZ0d\dGdHZ1d\dIdJZ2ejdKejj3ejj4gdbdMdNZ5d\dOdPZ6d[dQdRZ7d[dSdTZ8d[dUdVZ9d\dWdXZ:dS )c    )annotationsN)	AwaitableCallable)AnyTypeUnion)AsyncIOWrapper)AsyncAutoWrapperTypetmp_pathpathlib.Pathreturn	trio.Pathc                 C  s   t | d S )Ntest)trioPath)r
    r   9usr/lib/python3.10/site-packages/trio/_tests/test_path.pypath   s   r   strmethod_name<tuple[Callable[[], object], Callable[[], Awaitable[object]]]c                 C  s(   t | }t| }t||t||fS N)pathlibr   r   getattr)r   r   Z	sync_pathZ
async_pathr   r   r   method_pair   s   

r   Nonec              	     sb   |  dI d H 4 I d H }t|tsJ W d   I d H  n1 I d H s%w   Y  |js/J d S Nw)open
isinstancer   closedr   fr   r   r   "test_open_is_async_context_manager   s
   (r#   c                    s0   t d} t| dksJ t| dksJ d S )Nr   s   test)r   r   r   bytesr   r   r   r   
test_magic$   s   
r&   z+list[tuple[EitherPathType, EitherPathType]]	cls_pairszcls_a,cls_bcls_aEitherPathTypecls_bc                   sr   | d|d}}||ksJ ||krJ | d|d}}||k s%J ||ks+J |d kr1J |d kr7J d S )N abr   )r(   r*   r,   r-   r   r   r   test_cmp_magic4   s   r.   z)list[tuple[PathOrStrType, PathOrStrType]]cls_pairs_strPathOrStrTypec                   sJ   | d|d}}|| }t |tjsJ t|tjddks#J d S )Nr,   r-   )r   r   r   r   osr   join)r(   r*   r,   r-   resultr   r   r   test_div_magicO   s
   r4   )foozfoo/bar/bazz./fooc                   s,   | |||}}t |t |ksJ d S r   )hash)r(   r*   r   r,   r-   r   r   r   test_hash_magicY   s   r7   c                   s$   dt | v s	J | jdksJ d S )Nnamer   )dirr8   r%   r   r   r   test_forwarded_propertiesd   s   r:   c                   sF   | j jdks	J | j jdksJ | j jd usJ d| j jv s!J d S )NresolvezPath.resolvezpathlib.Path.resolve)r;   __name____qualname____doc__r%   r   r   r   test_async_method_signaturek   s
   r?   is_diris_filec                   s2   t d| \}}| }| I d H }||ksJ d S N.)r   r   methodZasync_methodr3   Zasync_resultr   r   r   test_compare_async_stat_methodsu   s
   rF   c                   s<   t t t| d W d    d S 1 sw   Y  d S )NZinvalid_fake_attr)pytestraisesAttributeErrorr   r%   r   r   r   test_invalid_name_not_wrapped      "rJ   absoluter;   c                   sJ   t d| \}}| }| I d H }t|tjsJ t|t|ks#J d S rB   )r   r   r   r   r   rD   r   r   r   test_async_methods_rewrap   s   rM   c                   sZ   |  d}| d}t|tjsJ ||d ksJ t|tjs#J ||d ks+J d S )Nr5   z.pyztest.py)	with_namewith_suffixr   r   r   )r   r
   rN   rO   r   r   r   test_forward_methods_rewrap   s   

rP   c                   s   t | jtjs
J d S r   )r   parentr   r   r%   r   r   r   test_forward_properties_rewrap   s   rR   c                   s(   | j  I d H } |  dsJ d S )Nzfile:///)rQ   r;   as_uri
startswithr%   r   r   r   #test_forward_methods_without_rewrap   s   rU   c                    s    t d} t| dksJ d S )NrC   ztrio.Path('.'))r   r   reprr%   r   r   r   	test_repr   s   
rW   c                   @  s   e Zd ZdZdZdS )MockWrappedunsupportedZprivateN)r<   
__module__r=   rY   _privater   r   r   r   rX          rX   c                   @  s   e Zd ZeZeZdS )_MockWrapperN)r<   rZ   r=   rX   Z	_forwardsZ_wrapsr   r   r   r   r]      r\   r]   r   MockWrapperc                     >   t t tti  W d    d S 1 sw   Y  d S r   )rG   rH   	TypeErrorWrapperTypegenerate_forwardsr^   r   r   r   r   test_type_forwards_unsupported      "rc   c                     r_   r   )rG   rH   r`   ra   generate_wrapsr^   r   r   r   r   test_type_wraps_unsupported   rd   rf   c                     $   t tdd i ttdrJ d S NrY   r[   )ra   rb   r^   hasattrr   r   r   r   test_type_forwards_private      rj   c                     rg   rh   )ra   re   r^   ri   r   r   r   r   test_type_wraps_private   rk   rl   meth(Callable[[trio.Path, trio.Path], object]c                   s6   |   I d H }|| |}|d u r| }||ksJ d S r   )rL   )r   rm   wrappedr3   r   r   r   test_path_wraps_path   s   
rp   c                     s<   t t td W d    d S 1 sw   Y  d S )N   )rG   rH   r`   r   r   r   r   r   r   test_path_nonpath   rK   rr   c              	     sb   t | dI d H 4 I d H }|jt| ksJ W d   I d H  d S 1 I d H s*w   Y  d S r   )r   Z	open_filer8   r1   fspathr!   r   r   r   test_open_file_can_open_path   s   .rt   c                   s  |   I d H  | d   I d H  | d d dI d H  | d dI d H  | d dI d H  dhddhd D ]&\}}t }| |I d H D ]}t|tjsTJ ||j	 qJ||ksaJ q;t }| 
dI d H D ]}t|tjswJ ||j	 qm|ddhksJ d S )Nr5   z_bar.txt    bar.txtzbar.dat)*.txtz**/*.txtrw   )mkdirwrite_bytesitemssetglobr   r   r   addr8   rglob)r   _patternZ_resultsentriesentryr   r   r   test_globmethods   s*   
r   c                   s   |   I d H  | d   I d H  | d dI d H  t }|  I d H D ]}t|tjs/J ||j q%|ddhks>J d S )Nr5   rv   ru   )	rx   ry   r{   iterdirr   r   r   r}   r8   )r   r   r   r   r   r   test_iterdir   s   r   c                     st   t tj I d H tjsJ ttj I d H tjdks!J ttj I d H t	 ks1J tjjj
s8J d S )N~)r   r   r   homer   r1   r   
expandusercwdgetcwdr>   r   r   r   r   test_classmethods  s
   $ r   )r
   r   r   r   )r   r   r   r   r   r   )r   r   r   r   )r   r   )r(   r)   r*   r)   r   r   )r(   r0   r*   r0   r   r   )r(   r)   r*   r)   r   r   r   r   )r   r   r   r   )r   r   r
   r   r   r   )r   r   rm   rn   r   r   );
__future__r   r1   r   collections.abcr   r   typingr   r   r   rG   r   Ztrio._file_ior   Z
trio._pathr	   ra   Zfixturer   r   r#   r&   r   r)   r   r0   r'   __annotations__ZmarkZparametrizer.   r/   r4   r7   r:   r?   rF   rJ   rM   rP   rR   rU   rW   rX   r]   r^   rc   rf   rj   rl   __init__joinpathrp   rr   rt   r   r   r   r   r   r   r   <module>   sv    

	





	



	













