o
    wi                     @   s\   d dl Z d dlZd dlZd dlZd dlmZ ddlmZ e j	dd Z
G dd dejZdS )	    N)join   )extended_iglobc                 c   sB    t t| |ddd}|V  W d    d S 1 sw   Y  d S )Nwutf8)encoding)openpjoin)dir_pathfilenamef r   `/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/Cython/Build/Tests/TestDependencies.pywritable_file
   s   "r   c                   @   sD   e Zd Zedd Zedd Zdd Zdd Zd	d
 Zdd Z	dS )TestGlobbingc                 C   s4  t  | _t | _| jj}t | dD ]}||d fD ]y}dD ]@}t||}t 	| t
|d}|d W d    n1 sBw   Y  t
|d}|d W d    n1 s\w   Y  q!t
|d}|d W d    n1 sww   Y  t
|d	}|d W d    n1 sw   Y  qqd S )
Nabcdxxyzfile2_pyx.pyxz""" PYX """file2_py.pyz
""" PY """file1_pyx.pyxfile1_py.py)osgetcwd	_orig_dirtempfileTemporaryDirectory_tmpdirnamechdirr	   makedirsr   write)cls	temp_pathdir1dir1xdir2r
   r   r   r   r   
setUpClass   s2   




zTestGlobbing.setUpClassc                 C   s   t | j | j  d S )N)r   r   r   r   cleanup)r"   r   r   r   tearDownClass'   s   zTestGlobbing.tearDownClassc                 C   sh   t |}t dd t|D }| || tjdkr0d|v r2t t|dd}| || d S d S d S )Nc                 s   s    | ]
}| d tjV  qdS )/N)replacer   sep).0pathr   r   r   	<genexpr>/   s    z+TestGlobbing.files_equal.<locals>.<genexpr>\r*   )sortedr   assertListEqualr   r,   r+   )selfpatternexpected_filesmatched_filesr   r   r   files_equal,   s   zTestGlobbing.files_equalc                 C   s   t dddt dddg}| d| | dg  | d| | d| | d	|d d
  | d|d d
  | d|d
d   | d|d
d   d S )Nar   r   r   za/x/*z	a/x/*.c12za/x/*.{py,pyx,c12}za/x/*.{py,pyx}za/x/*.{pyx}   z	a/x/*.pyxz
a/x/*.{py}za/x/*.py)r	   r7   )r3   ax_filesr   r   r   test_extended_iglob_simple7   s   z'TestGlobbing.test_extended_iglob_simplec              	      s~  dD ]  fdddD }|   d | |   d g  |   d | |   d | |   d	 |d d d
  |   d |d d d
  |   d |dd d
  |   d |dd d
  dD ]X fdddD } d  d }|  |d | |  |d | |  |d |d d d
  |  |d |d d d
  |  |d |dd d
  |  |d |dd d
  qcqd S )Nadc                    s"   g | ]}d D ]}t  ||qqS )r   r   r	   r-   dirnamer   )basedirr   r   
<listcomp>D   s    
z@TestGlobbing.test_extended_iglob_simple_star.<locals>.<listcomp>r   z/*/*z/*/*.c12z/*/*.{py,pyx,c12}z/*/*.{py,pyx}z
/*/*.{pyx}r   z/*/*.pyxz	/*/*.{py}r9   z/*/*.pyzxy*c                    s.   g | ]}d |fv rdD ]}t  ||qqS )*r=   r>   r?   rA   subdirr   r   rB   S   s    
r*   rC   z
*.{py,pyx}z*.{pyx}z*.pyxz*.{py}z*.py)r7   )r3   filesr.   r   rD   r   test_extended_iglob_simple_starB   s2   
z,TestGlobbing.test_extended_iglob_simple_starc                 C   s  t d}dd |D }dd |D | }| d| | d| | d| | d| | d	g  | d
g  | d| | d| | d| | d| | d| | d| | d| | d| | d| | d|d d d  | d|d d d  | d|d d d  | d|d d d  | d|d d d  | d|dd d  | d|dd d  | d|dd d  | d|dd d  d S )N.c                 S   s,   g | ]}d D ]}dD ]}t |||q
qqS )r   r=   r>   )r-   rA   r@   r   r   r   r   rB   c   s    

z@TestGlobbing.test_extended_iglob_double_star.<locals>.<listcomp>c                 S   s    g | ]}d D ]}t ||qqS ))r   r   r>   )r-   rA   r   r   r   r   rB   i   s    z*/*/*z*/*/**/*z*/**/*.*z**/*.*z
*/**/*.c12z**/*.c12z*/*/*.{py,pyx,c12}z*/*/**/*.{py,pyx,c12}z*/**/*/*.{py,pyx,c12}z**/*/*/*.{py,pyx,c12}z**/*.{py,pyx,c12}z*/*/*.{py,pyx}z**/*/*/*.{py,pyx}z*/**/*/*.{py,pyx}z**/*.{py,pyx}z*/*/*.{pyx}r   z
**/*.{pyx}z*/**/*/*.pyxz	*/*/*.pyxz**/*.pyxz
*/*/*.{py}r9   z	**/*.{py}z*/*/*.pyz**/*.py)r   listdirr7   )r3   basedirsrF   	all_filesr   r   r   test_extended_iglob_double_stara   sB   
z,TestGlobbing.test_extended_iglob_double_starN)
__name__
__module____qualname__classmethodr'   r)   r7   r;   rG   rL   r   r   r   r   r      s    

r   )
contextlibos.pathr   r   unittestr   r	   Dependenciesr   contextmanagerr   TestCaser   r   r   r   r   <module>   s    
