U
    iâËd_  ã                   @   sB   d dl Z d dlZd dlZd dlZd dlmZ G dd„ de jƒZdS )é    N)ÚPathc                   @   s   e Zd Zdd„ ZdS )ÚTestUnpickleDeletedModulec              	   C   s¢   d  ddddg¡}d}t ¡ �N}tj |¡ t|› d|› d�ƒ}t|d	ƒ}| |¡ | 	¡  d
dl
m} W 5 Q R X tj|= t |¡}t |¡}|  |dƒd¡ dS )a“  Create a module that uses Numba, import a function from it.
        Then delete the module and pickle the function. The function
        should load from the pickle without a problem.

        Note - This is a simplified version of how Numba might be used
        on a distributed system using e.g. dask distributed. With the
        pickle being sent to the worker but not the original module.
        Ú
zfrom numba import vectorizez @vectorize(['float64(float64)'])zdef inc1(x):z    return x + 1Ú
tmp_moduleú/z.pyÚar   )Úinc1é   é   N)ÚjoinÚtempfileÚTemporaryDirectoryÚsysÚpathÚappendr   ÚopenÚwriteÚcloser   r   ÚmodulesÚpickleÚdumpsÚloadsÚassertEqual)ÚselfÚsourceÚmodnameZtmp_dirÚfilenameÚfr   Zpkl© r   úa/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numba/tests/test_unpickle_without_module.pyÚ"test_loading_pickle_with_no_module	   s&    üÿ





z<TestUnpickleDeletedModule.test_loading_pickle_with_no_moduleN)Ú__name__Ú
__module__Ú__qualname__r    r   r   r   r   r      s   r   )Zunittestr   r   r   Úpathlibr   ZTestCaser   r   r   r   r   Ú<module>   s
   