U
    L?h                     @   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
   H/var/www/html/venv/lib/python3.8/site-packages/sympy/testing/tmpfiles.pytmp_file   s    zTmpFileManager.tmp_filec                 C   s   | j | |S r   )tmp_foldersr   r   r
   r
   r   
tmp_folder   s    zTmpFileManager.tmp_folderc                 C   sH   | j r(| j  }tj|r t| q | jrD| j }t| q(d S r   )	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 5 t   X d S 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   