3
d๋  ใ               @   s   d dl Z d dlmZ d dlZd dlmZmZmZ d dlm	Z	 G dd deZ
G dd deZG d	d
 d
ejZG dd dejZdS )้    N)ฺPath)ฺFileฺ	HasTraitsฺ
TraitError)ฺrequires_traitsuic               @   s    e Zd ZeddZeddZdS )ฺExampleModelT)ฺexistsFN)ฺ__name__ฺ
__module__ฺ__qualname__r   ฺ	file_nameฺnew_file_nameฉ r   r   ๚8/tmp/pip-build-7vycvbft/traits/traits/tests/test_file.pyr      s   
r   c               @   s   e Zd Ze ZdS )ฺFastExampleModelN)r	   r
   r   r   r   r   r   r   r   r      s   r   c               @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )ฺFileTestCasec             C   s   t td}tjj|_d S )N)r   )r   ฺ__file__ฺosฺpathr   )ฺselfฺexample_modelr   r   r   ฺtest_valid_file   s    
zFileTestCase.test_valid_filec             C   s   t ttd d S )N)r   )r   r   r   )r   r   r   r   ฺtest_valid_pathlike_file"   s    z%FileTestCase.test_valid_pathlike_filec          	   C   s*   t td}| jt d|_W d Q R X d S )N)r   znot_valid_path!#!#!#)r   r   ฺassertRaisesr   r   )r   r   r   r   r   ฺtest_invalid_file%   s    
zFileTestCase.test_invalid_filec          	   C   s.   t td}| jt td|_W d Q R X d S )N)r   znot_valid_path!#!#!#)r   r   r   r   r   r   )r   r   r   r   r   ฺtest_invalid_pathlike_file+   s    
z'FileTestCase.test_invalid_pathlike_filec          	   C   s2   t td}| jt tjjt|_W d Q R X d S )N)r   )r   r   r   r   r   r   ฺdirnamer   )r   r   r   r   r   ฺtest_directory1   s    
zFileTestCase.test_directoryc          
   C   s6   t td}| jt ttjjt|_W d Q R X d S )N)r   )	r   r   r   r   r   r   r   r   r   )r   r   r   r   r   ฺtest_pathlike_directory7   s    
z$FileTestCase.test_pathlike_directoryc          	   C   s*   t td}| jt d|_W d Q R X d S )N)r   ้   )r   r   r   r   r   )r   r   r   r   r   ฺtest_invalid_type=   s    
zFileTestCase.test_invalid_typec             C   s   t td}d|_d S )N)r   ฺ.)r   r   r   )r   r   r   r   r   ฺ	test_fastC   s    
zFileTestCase.test_fastc             C   s   t  }| jt}d|_W d Q R X | jdt|j | jdt|j | jt}d|_W d Q R X | jdt|j | jdt|j d S )N้/   za string or os.PathLike objectzreferring to an existing fileฺexist)	r   r   r   r   ZassertInฺstrฺ	exceptionr   ZassertNotIn)r   r   Zexc_cmr   r   r   ฺtest_info_textG   s    zFileTestCase.test_info_textN)r	   r
   r   r   r   r   r   r   r   r    r"   r'   r   r   r   r   r      s   r   c               @   s   e Zd Zedd ZdS )ฺTestCreateEditorc             C   sD   t dd}|j }| j|jd t dd}|j }| j|jd d S )NT)r   ฺopenFฺsave)r   Zcreate_editorZassertEqualZdialog_style)r   ฺxZeditorr   r   r   ฺ(test_exists_controls_editor_dialog_styleV   s    

z9TestCreateEditor.test_exists_controls_editor_dialog_styleN)r	   r
   r   r   r,   r   r   r   r   r(   T   s   r(   )r   Zpathlibr   ZunittestZ
traits.apir   r   r   Z$traits.testing.optional_dependenciesr   r   r   ZTestCaser   r(   r   r   r   r   ฺ<module>   s   7