o
    à8Va  ã                   @   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   ó   | j  |¡ |S ©N)Ú	tmp_filesÚadd©ÚclsÚname© r   ú8/usr/lib/python3/dist-packages/sympy/testing/tmpfiles.pyÚtmp_file   ó   zTmpFileManager.tmp_filec                 C   r   r   )Útmp_foldersr   r   r   r   r   Ú
tmp_folder   r   zTmpFileManager.tmp_folderc                 C   sT   | j r| j  ¡ }tj |¡rt |¡ | j s| jr(| j ¡ }t |¡ | jsd S d S r   )	r   ÚpopÚosÚpathÚisfileÚremover   ÚshutilÚrmtree)r	   ÚfileZfolderr   r   r   Úcleanup   s   

ý

þzTmpFileManager.cleanupN)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 t  ¡  d S t  ¡  w r   )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
    