
    
d                     x    d 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             Z	d Z
d Zd Zd	 Zd
 ZdS )z#Tests for the User Module Reloader.    N)to_text_string)UserModuleReloaderc                      t                     t          j        vr,t          j                            t                                 fd}|S )z@Create a simple module in tmpdir as an example of a user module.c                                          |                               d          }d}|                    |                               |                               d          }|                    d           d S )Nzbar.pyz(
def square(x):
    return x**2
        z__init__.py#)mkdirjoinwrite)modnamemodfilecode	init_filetmpdirs       Glib/python3.11/site-packages/spyder_kernels/customize/tests/test_umr.pycreate_modulez"user_module.<locals>.create_module   st    ,,w'',,X66 	dKK((--m<<	    )r   syspathappend)r   r   s   ` r   user_moduler      sW     fSX--v..///	 	 	 	 	 r   c                      | d           dt           j        d<   t                      }ddl}|                    |d          dk    sJ dt           j        d<   dS )z\
    Test that the UMR doesn't try to reload modules when Cython
    support is active.
    fooTrueSPY_RUN_CYTHONr   NFFalse)osenvironr   r   is_module_reloadable)r   umrr   s      r   test_umr_skip_cythonr    +   so     K $*BJ  

CJJJ##C//58888 $+BJ   r   c                      | d           dt           j        d<   t                      }ddlm} |                                 |j        ddgk     dS )	z0Test that UMR's run method is working correctly.foo1r   SPY_UMR_VERBOSEr   )squarer   zfoo.barN)r   r   r   foo1.barr$   runmodnames_to_reload)r   r   r$   s      r   test_umr_runr(   @   sh     K %+BJ ! 

CGGIIIui00000r   c                 l     | d           t                      }ddl}d|j        v sJ d|j        vsJ dS )z7Test that UMR's previos_modules is working as expected.foo2r   NIPython)r   r*   previous_modules)r   r   r*   s      r   test_umr_previous_modulesr-   P   sX     K 

CKKK,,,,,-------r   c                      t                      } |                     d          sJ |                     d          sJ |                     d          sJ |                     d          rJ dS )z6Test that the UMR skips modules according to its name.
tensorflowpytorchspyder_kernelsr   N)r   is_module_in_namelist)r   s    r   test_umr_namelistr3   ]   s|    


C$$\22222$$Y/////$$%566666((///////r   c                      | d           t                      }ddl}|                    |d          rJ ddl}|                    |d          rJ ddl}|                    |d          sJ dS )z4Test that the UMR only tries to reload user modules.foo3r   Nxmlnumpy)r   r6   r   r7   r5   )r   r   r6   r7   r5   s        r   test_umr_reload_modulesr8   g   s     K 

C JJJ''U33333 LLL''w77777 KKK##D&1111111r   )__doc__r   r   pytestspyder_kernels.py3compatr   spyder_kernels.customize.umrr   fixturer   r    r(   r-   r3   r8    r   r   <module>r?      s    * ) 
			 



  4 3 3 3 3 3 ; ; ; ; ; ;   &+ + +*1 1 1 
. 
. 
.0 0 02 2 2 2 2r   