o
    4@Hh                     @  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Zd dlZd dl	m
Z
 er/d dlmZmZ ejdXd
dZdYddZejjejdkdddZddZejjejdkdddZddZd[ddZdZd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[d0d1Z%ejdd2d3gd_d4d5Z&d[d6d7Z'ejdd8d9gd_d:d;Z(d`d<d=Z)d[d>d?Z*d[d@dAZ+dZdBdCZ,ejdDejj-ejj.gdadFdGZ/dZdHdIZ0d[dJdKZ1d[dLdMZ2d[dNdOZ3d[dPdQZ4dZdRdSZ5ejdTej6j7ej6j8ej6j9ej6j:gdbdVdWZ;dS )c    )annotationsN)TYPE_CHECKINGUnion)AsyncIOWrapper)	AwaitableCallabletmp_pathpathlib.Pathreturn	trio.Pathc                 C  s   t | d S )Ntest)trioPath)r    r   U/home/air/sanwanet/gpt-api/venv/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   	sync_path
async_pathr   r   r   method_pair   s   

r   ntzOS is not posix)reasonNonec                   C     t t tjs
J d S r   )
isinstancer   r   	PosixPathr   r   r   r   test_instantiate_posix      r!   zOS is not Windowsc                   C  r   r   )r   r   r   WindowsPathr   r   r   r   test_instantiate_windows#   r"   r$   c              	     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)openr   r   closedr   fr   r   r   "test_open_is_async_context_manager(   s
   (r+   c                  C  s.   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_pairs)cls_acls_br0   EitherPathTyper1   c                 C  sp   | d|d}}||ksJ ||krJ | d|d}}||k s$J ||ks*J |d kr0J |d kr6J d S )N abr   )r0   r1   r4   r5   r   r   r   test_cmp_magic?   s   r6   z)list[tuple[PathOrStrType, PathOrStrType]]cls_pairs_strPathOrStrTypec                 C  sH   | d|d}}|| }t |tjsJ t|tjddks"J d S )Nr4   r5   )r   r   r   r   osr   join)r0   r1   r4   r5   resultr   r   r   test_div_magicZ   s   r<   )foozfoo/bar/bazz./fooc                 C  s*   | |||}}t |t |ksJ d S r   )hash)r0   r1   r   r4   r5   r   r   r   test_hash_magicd   s   
r?   c                 C  s"   dt | v sJ | jdksJ d S )Nnamer   )dirr@   r-   r   r   r   test_forwarded_propertiesr   s   rB   c                 C  sH   | j jdksJ | j jdksJ | j jd usJ | j j| j jv s"J d S )NresolvezPath.resolve)rC   __name____qualname____doc__r-   r   r   r   test_async_method_signaturey   s   rG   is_diris_filec                   s2   t d| \}}| }| I d H }||ksJ d S N.)r   r   methodasync_methodr;   async_resultr   r   r   test_compare_async_stat_methods   s
   rP   c                 C  s:   t t t| d W d    d S 1 sw   Y  d S )Ninvalid_fake_attr)pytestraisesAttributeErrorr   r-   r   r   r   test_invalid_name_not_wrapped      "rU   absoluterC   c                   sJ   t d| \}}| }| I d H }t|tjsJ t|t|ks#J d S rJ   )r   r   r   r   r   rL   r   r   r   test_async_methods_rewrap   s   rX   c                 C  sX   |  d}| d}t|tjsJ ||d ksJ t|tjs"J ||d ks*J d S )Nr=   z.pyztest.py)	with_namewith_suffixr   r   r   )r   r   rY   rZ   r   r   r   test_forward_methods_rewrap   s   

r[   c                 C  s   t | jtjs	J d S r   )r   parentr   r   r-   r   r   r   test_forward_properties_rewrap   s   r]   c                 C  s   dt | dv sJ d S )Nztotally-unique-path)r   joinpathr-   r   r   r   #test_forward_methods_without_rewrap   s   r_   c                  C  s   t d} t| dksJ d S )NrK   ztrio.Path('.'))r   r   reprr-   r   r   r   	test_repr   s   
ra   meth(Callable[[trio.Path, trio.Path], object]c                   s6   |   I d H }|| |}|d u r| }||ksJ d S r   )rW   )r   rb   wrappedr;   r   r   r   test_path_wraps_path   s   
re   c                   C  s:   t t td W d    d S 1 sw   Y  d S )N   )rR   rS   	TypeErrorr   r   r   r   r   r   test_path_nonpath   rV   rh   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   	open_filer@   r9   fspathr)   r   r   r   test_open_file_can_open_path   s   .rk   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 )Nr=   z_bar.txt    bar.txtzbar.dat)*.txtz**/*.txtrn   )mkdirwrite_bytesitemssetglobr   r   r   addr@   rglob)r   _pattern_resultsentriesentryr   r   r   test_globmethods   s*   
rz   c                   s(   | j  I d H } |  dsJ d S )Nzfile:///)r\   rC   as_uri
startswithr-   r   r   r   test_as_uri   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 )Nr=   rm   rl   )	ro   rp   rr   iterdirr   r   r   rt   r@   )r   rx   ry   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   r9   r   
expandusercwdgetcwdrF   r   r   r   r   test_classmethods   s
   $ r   wrapper2Callable[[Callable[[], None]], Callable[[], None]]c                 C  s    | ddd}|j d u sJ d S )Nr
   r   c                   S  s   d S r   r   r   r   r   r   func_without_docstring  s   z@test_wrapping_without_docstrings.<locals>.func_without_docstringr
   r   )rF   )r   r   r   r   r    test_wrapping_without_docstrings  s   r   )r   r	   r
   r   )r   r   r   r   r
   r   r   )r   r   r
   r   )r0   r2   r1   r2   r
   r   )r0   r8   r1   r8   r
   r   )r0   r2   r1   r2   r   r   r
   r   )r   r   r
   r   )r   r   r   r	   r
   r   )r   r   rb   rc   r
   r   )r   r   r
   r   )<
__future__r   r9   r   typingr   r   rR   r   trio._file_ior   collections.abcr   r   fixturer   r   markskipifr@   r!   r$   r+   r.   typer   r2   r   r8   r/   __annotations__parametrizer6   r7   r<   r?   rB   rG   rP   rU   rX   r[   r]   r_   ra   __init__r^   re   rh   rk   rz   r}   r   r   _path_wraps_async_wrap_method_wrap_method_path_wrap_method_path_iterabler   r   r   r   r   <module>   s    
	






	
	


	











	