U
    {h                     @   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   s*   t t| |ddd}|V  W 5 Q R X d S )Nwutf8)encoding)openpjoin)dir_pathfilenamef r   G/tmp/pip-unpacked-wheel-fhl22ezh/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   s   t  | _t | _| jj}t | dD ]}||d fD ]}dD ]X}t||}t 	| t
|d}|d W 5 Q R X t
|d}|d W 5 Q R X qBt
|d}|d W 5 Q R X t
|d	}|d W 5 Q R X q:q*d S )
NZ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)clsZ	temp_pathZdir1Zdir1xZdir2r
   r   r   r   r   
setUpClass   s"    




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   s`   t |}t dd t|D }| || tjdkr\d|kr\t t|dd}| || 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   ZassertListEqualr   r'   r&   )selfpatternZexpected_filesZ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	   r/   )r-   Zax_filesr   r   r   test_extended_iglob_simple7   s    z'TestGlobbing.test_extended_iglob_simplec              	      s  dD ]t  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 ] 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
  qq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}r1   z/*/*.pyzxy*c                    s.   g | ]&}d |fkrdD ]}t  ||qqS )*r4   r5   r6   r8   subdirr   r   r9   S   s
    r%   r:   z
*.{py,pyx}z*.{pyx}z*.pyxz*.{py}z*.py)r/   )r-   filesr)   r   r;   r   test_extended_iglob_simple_starB   s.    

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   r4   r5   )r(   r8   r7   r   r   r   r   r9   c   s     z@TestGlobbing.test_extended_iglob_double_star.<locals>.<listcomp>c                 S   s    g | ]}d D ]}t ||qqS ))r   r   r5   )r(   r8   r   r   r   r   r9   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}r1   z	**/*.{py}z*/*/*.pyz**/*.py)r   listdirr/   )r-   Zbasedirsr=   	all_filesr   r   r   test_extended_iglob_double_stara   sB    
z,TestGlobbing.test_extended_iglob_double_starN)
__name__
__module____qualname__classmethodr"   r$   r/   r2   r>   rB   r   r   r   r   r      s   

r   )
contextlibos.pathr   r   Zunittestr   r	   ZDependenciesr   contextmanagerr   ZTestCaser   r   r   r   r   <module>   s   
