B
    %d                 @   sJ   d Z ddlmZ ddlZddlZddgZG dd dZG dd deZdS )z(Provide base classes for the test system    )TestCaseNTestBaseFileCreatorc               @   sN   e Zd ZdZdZdddZdd Zdd	 Zd
d Ze	dd Z
e	dd ZdS )r   zA instance which creates a temporary file with a prefix and a given size
    and provides this info to the user.
    Once it gets deleted, it will remove the temporary file as well.)_size_path c          	   C   sj   |st dtj|d| _|| _t| jd}||d  |d W d Q R X tj	
| j	|ksft d S )NzRequire size to be larger 0)prefixwb      1)AssertionErrortempfilemktempr   r   openseekwriteospathgetsize)selfsizer   fp r   [/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/smmap/test/lib.py__init__   s    zFileCreator.__init__c             C   s*   yt | j W n tk
r$   Y nX d S )N)r   remover   OSError)r   r   r   r   __del__   s    zFileCreator.__del__c             C   s   | S )Nr   )r   r   r   r   	__enter__%   s    zFileCreator.__enter__c             C   s   |    d S )N)r   )r   exc_type	exc_value	tracebackr   r   r   __exit__(   s    zFileCreator.__exit__c             C   s   | j S )N)r   )r   r   r   r   r   +   s    zFileCreator.pathc             C   s   | j S )N)r   )r   r   r   r   r   /   s    zFileCreator.sizeN)r   )__name__
__module____qualname____doc__	__slots__r   r   r   r"   propertyr   r   r   r   r   r   r      s   
c               @   s    e Zd ZdZdZedd ZdS )r   zFoundation used by all testsiK&z c             C   s   d S )Nr   )clsr   r   r   setUpAll?   s    zTestBase.setUpAllN)r#   r$   r%   r&   Zk_window_test_sizeclassmethodr*   r   r   r   r   r   6   s   )r&   Zunittestr   r   r   __all__r   r   r   r   r   r   <module>   s   +