a
    ¦ˆcë  ã                   @   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   úY/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/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 r   )r   r   r   )r   r   r   r   Útest_valid_pathlike_file"   s    z%FileTestCase.test_valid_pathlike_filec                 C   s>   t td�}|  t¡� d|_W d   ƒ n1 s00    Y  d S ©Nr   znot_valid_path!#!#!#©r   r   ÚassertRaisesr   r   r   r   r   r   Útest_invalid_file%   s    
zFileTestCase.test_invalid_filec                 C   sB   t td�}|  t¡� tdƒ|_W d   ƒ n1 s40    Y  d S r   )r   r   r   r   r   r   r   r   r   r   Útest_invalid_pathlike_file+   s    
z'FileTestCase.test_invalid_pathlike_filec                 C   sF   t td�}|  t¡� tj t¡|_W d   ƒ n1 s80    Y  d S r   )r   r   r   r   r   r   Údirnamer   r   r   r   r   Útest_directory1   s    
zFileTestCase.test_directoryc                 C   sJ   t td�}|  t¡�" ttj t¡ƒ|_W d   ƒ n1 s<0    Y  d S 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�}|  t¡� d|_W d   ƒ n1 s00    Y  d S )Nr   é   r   r   r   r   r   Útest_invalid_type=   s    
zFileTestCase.test_invalid_typec                 C   s   t td�}d|_d S )Nr   Ú.)r   r   r   r   r   r   r   Ú	test_fastC   s    
zFileTestCase.test_fastc                 C   s²   t ƒ }|  t¡�}d|_W d   ƒ n1 s,0    Y  |  dt|jƒ¡ |  dt|jƒ¡ |  t¡�}d|_W d   ƒ n1 s€0    Y  |  dt|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d¡ t dd�}| ¡ }|  |jd¡ d S )NTr   ÚopenFÚsave)r   Zcreate_editorÚ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   r3   r   r   r   r   r.   T   s   r.   )r   Úpathlibr   ZunittestZ
traits.apir   r   r   Z$traits.testing.optional_dependenciesr   r   r   ZTestCaser   r.   r   r   r   r   Ú<module>   s   7