U
    ui3                     @   sR   d dl Z d dlmZ d dlZd dlmZ d dlmZ d dlm	Z	 G dd dZ
dS )    N)mock)
build_clib)Distribution)DistutilsSetupErrorc                   @   s0   e Zd Zeddd Zeddd ZdS )TestBuildCLibz2setuptools.command.build_clib.newer_pairwise_groupc              	   C   s  t  }t|}dddifg}tt || W 5 Q R X d}ddg|dfg}tt || W 5 Q R X ddi}ddg|dfg}tt || W 5 Q R X ddi}ddg|dfg}tt || W 5 Q R X tj|jd|_g g f|_	d	d
d}ddg|dfg}|| dddgg|j
d ksBt|jjjrRt|jjjdksft|j  d|_	|| |jjjdkst|jjjdkstd S )Nexamplesourceszbroken.cZsome_stringzsource.cr   obj_deps specglobal.h	example.hr   	example.cr   r   r   r      )r   r   pytestZraisesr   build_librariesr   	MagicMockcompilerreturn_value	call_argsAssertionErrorcompilecalledZcreate_static_libZ
call_countZ
reset_mock)self
mock_newerdistcmdlibsr
    r#   D/tmp/pip-unpacked-wheel-9osl9suo/setuptools/tests/test_build_clib.pytest_build_libraries   s<    




z"TestBuildCLib.test_build_librariesc           	      C   s   t  }t|}tj|jd|_g g f|_ddg}|}ddd}d||dfg}|| |jd	 }||kr|t	|t
|}qbd||dfg}|| ||jd	 kstd S )
Nr   za-example.cr   r   r   r   r   r	   r   )r   r   r   r   r   r   r   r   randomsamplelenr   )	r   r   r    r!   Zoriginal_sourcesr   r
   r"   Zcomputed_call_argsr#   r#   r$   !test_build_libraries_reproducible<   s    




z/TestBuildCLib.test_build_libraries_reproducibleN)__name__
__module____qualname__r   patchr%   r)   r#   r#   r#   r$   r      s   
.r   )r&   Zunittestr   r   Zsetuptools.command.build_clibr   Zsetuptools.distr   distutils.errorsr   r   r#   r#   r#   r$   <module>   s   