B
    e‹d  ã               @   s.   d Z ddlZddlZG dd„ dƒZdd„ ZdS )zN
This module adds context manager for temporary files generated by the tests.
é    Nc               @   sH   e Zd ZdZedƒZedƒZed
dd„ƒZeddd„ƒZ	edd„ ƒZ
d	S )ÚTmpFileManagerzP
    A class to track record of every temporary files created by the tests.
    Ú c             C   s   | j  |¡ |S )N)Ú	tmp_filesÚadd)ÚclsÚname© r   úc/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/sympy/testing/tmpfiles.pyÚtmp_file   s    zTmpFileManager.tmp_filec             C   s   | j  |¡ |S )N)Útmp_foldersr   )r   r   r   r   r	   Ú
tmp_folder   s    zTmpFileManager.tmp_folderc             C   sP   x*| j r*| j  ¡ }tj |¡rt |¡ qW x| jrJ| j ¡ }t |¡ q.W d S )N)	r   ÚpopÚosÚpathÚisfileÚremover   ÚshutilÚrmtree)r   ÚfileÚfolderr   r   r	   Úcleanup   s    

zTmpFileManager.cleanupN)r   )r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úsetr   r   Úclassmethodr
   r   r   r   r   r   r	   r   	   s   r   c                s   ‡ fdd„}|S )zP
    A decorator to help test codes remove temporary files after the tests.
    c                  s   z
ˆ ƒ  W d t  ¡  X d S )N)r   r   r   )Ú	test_funcr   r	   Úwrapper_function(   s    
z+cleanup_tmp_files.<locals>.wrapper_functionr   )r   r   r   )r   r	   Úcleanup_tmp_files$   s    r   )r   r   r   r   r   r   r   r   r	   Ú<module>   s   