U
    ,d                     @   sp   d dl Z d dlZ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mZ d dlmZmZ G dd deZdS )    N)types)TestCasetemp_directory)inspect_functioninspect_modulec                   @   s6   e Zd ZdddZdd Zdd Zdd	 Zd
d ZdS )TestInspectorFc                 C   s~   |  |t | d| |d }|d kr4| | nF|  |tj | d| |  |d t | d| |  |d t d S )N
numba_typeZ	explainedsource_infos)assertIsInstancedictassertInassertFalser   Typestr)selfinfomust_be_definedr    r   9/tmp/pip-unpacked-wheel-eu7e0c37/numba/tests/test_help.pycheck_function_descriptor   s    z'TestInspector.check_function_descriptorc                 C   s   t t}| j|dd d S )NTr   )r   ranger   )r   r   r   r   r   test_inspect_function_on_range   s    z,TestInspector.test_inspect_function_on_rangec                 C   s   t tj}| j|dd |d }| t|d d}| D ]h}| |d t | |d t | |d t | |d t | |d	 t	 | 
d
| |d7 }q<| |t| d S )NTr   r	   r   kindnamesigfilenamelinesZ	docstring   )r   npallr   assertGreaterlenvaluesr
   r   tupler   assertEqual)r   r   r	   cZsrcinfor   r   r   test_inspect_function_on_np_all    s    

z-TestInspector.test_inspect_function_on_np_allc                 C   sh   d}t tD ]J}| |d tj | |d t | t|d  | | |d7 }q| 	|d d S )Nr   moduler   objr   )
r   builtinsr
   pytypes
ModuleTyper   
assertTruecallabler   r!   )r   r&   itr   r   r   test_inspect_module0   s    

z!TestInspector.test_inspect_modulec              	   C   s  t jddg}tdt| jj}tj|d}|d }|d|dg }| 	tj
| t| | tj
| |d|dd	dg }|d
 }| 	tj
| t| | tj
| |d|dddg }| tj}tj|tjd W 5 Q R X | d|jj  d S )Nz-mznumba.misc.help.inspectorz{}.{}outz.htmlz--filemathz--formatZrstz.rstZfoo)stderrz'foo' is not supported)sys
executabler   format__name__	__class__ospathjoinr   isfile
subprocesscheck_outputr-   assertRaisesCalledProcessErrorSTDOUTr   	exceptionstdoutdecode)r   Zcmdbasedirpathr   Zexpected_fileZcmdsZraisesr   r   r   test_inspect_cli:   s*    


zTestInspector.test_inspect_cliN)F)r7   
__module____qualname__r   r   r'   r0   rF   r   r   r   r   r      s
   

r   )r4   r=   r   r+   os.pathr9   Znumpyr   r*   Z
numba.coreZnumba.tests.supportr   r   Znumba.misc.help.inspectorr   r   r   r   r   r   r   <module>   s   