3
Kd                 @   s   d Z ddlZddlZddlZddlmZ ddlZddlZddl	m
Z
 ddlmZ dd Zejjd	d
dgddgejjdddd Zdd Zdd Zejjdddgdd ZdS )z0See https://github.com/numpy/numpy/pull/11937.

    N)import_module)assert_equal   )utilc               C   s(   t j stjd t j s$tjd d S )NzNeeds C compilerzNeeds FORTRAN 77 compiler)r   Zhas_c_compilerpytestskipZhas_f77_compiler r   r   Z/var/www/html/virt/lib64/python3.6/site-packages/numpy/f2py/tests/test_compile_function.pysetup_module   s    
r
   
extra_argsz--nooptz--debugz--noopt --debug z$Imported module seems never deleted.)reasonc       
      C   s   d}t j }t j }tj }tjj|ttj	 d }xv|d gD ]j}z"tj
| tjj||| |d}W d tj
| X t|d tjdkr@t|}|j }	t|	d tj|= q@W d S )NzT
        integer function foo()
        foo = 10 + 5
        return
        end
    z.f)
modulenamer   	source_fnr   win32   )r   Zget_module_dirZget_temp_module_nameosgetcwdpathjoinstruuiduuid4chdirnumpyf2pycompiler   sysplatformr   Zfoomodules)
r   fsourceZmoddirmodnamecwdtargetr   ret_valZreturn_checkZcalc_resultr   r   r	   test_f2py_init_compile   s(    



r%   c              C   s   t jjd} t| d d S )Ns   invalidr   )r   r   r   r   )r$   r   r   r	   test_f2py_init_compile_failureV   s    r&   c              C   s4   z&t j} dt _tjjd}t|d W d | t _X d S )Nzdoes not exists   invalid   )r   
executabler   r   r   r   )tempr$   r   r   r	   test_f2py_init_compile_bad_cmd]   s    r*   r    z'program test_f2py
end program test_f2pys'   program test_f2py
end program test_f2pyc             C   sH   t j }z.t jt|  tjj|ddd}t|d W d t j| X d S )Ntest_compile_from_stringsz.f90)r   	extensionr   )r   r   r   r   r   r   r   r   )Ztmpdirr    r"   r$   r   r   r	   r+   o   s    r+   )__doc__r   r   r   	importlibr   r   Z
numpy.f2pyr   Znumpy.testingr   r   r   r
   markZparametrizeZleaks_referencesr%   r&   r*   r+   r   r   r   r	   <module>   s"   	: