U
    md                     @   s   d Z ddlmZ ddlmZmZ ddlmZmZm	Z	 ddl
ZddlZddlZG dd deZG d	d
 d
eZG dd deZG dd deZG dd deZdd ZdS )zv
    Common high-level operations test

    Tests features common to all high-level objects, like the .name property.
    )File)is_hdf5Empty   )utTestCaseUNICODE_FILENAMESNc                   @   s   e Zd Zdd Zdd ZdS )BaseTestc                 C   s   t |  d| _d S Nw)r   mktempfself r   M/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/h5py/tests/test_base.pysetUp   s    zBaseTest.setUpc                 C   s   | j r| j   d S N)r   closer   r   r   r   tearDown   s    zBaseTest.tearDownN)__name__
__module____qualname__r   r   r   r   r   r   r	      s   r	   c                   @   s   e Zd ZdZdd ZdS )TestNamez>
        Feature: .name attribute returns the object name
    c                 C   s   | j d}| |jd dS )z" Anonymous objects have name None N)r   create_groupZassertIsnamer   grpr   r   r   test_anonymous(   s    zTestName.test_anonymousN)r   r   r   __doc__r   r   r   r   r   r   "   s   r   c                   @   s   e Zd ZdZdd ZdS )
TestParentzG
        test the parent group of the high-level interface objects
    c              	   C   sV   | j d }| t |j W 5 Q R X | j d}|d}|jj}| |d d S )NbarZfooz/bar)r   r   assertRaises
ValueErrorparentr   assertEqual)r   r   Zsub_grpr$   r   r   r   test_object_parent3   s    
zTestParent.test_object_parentN)r   r   r   r   r&   r   r   r   r   r    -   s   r    c                       s8   e Zd ZdZ fddZdd Zdd Zdd	 Z  ZS )
TestMappingzX
        Test if the registration of Group as a
        Mapping behaves as expected
    c                    s2   t    d}| jd| _| jjd|| _d S )N)abr!   x)superr   r   r   r   attrscreateattrr   data	__class__r   r   r   G   s    
zTestMapping.setUpc                 C   s8   | j  }| t|t | j }| t|t d S r   )r   keysassertIsInstancereprstrr   )r   Zkey_1Zkey_2r   r   r   	test_keysM   s    

zTestMapping.test_keysc                 C   s8   | j  }| t|t | j }| t|t d S r   )r   valuesr4   r5   r6   r   )r   Zvalue_1Zvalue_2r   r   r   test_valuesS   s    

zTestMapping.test_valuesc                 C   s8   | j  }| t|t | j }| t|t d S r   )r   itemsr4   r5   r6   r   )r   Zitem_1Zitem_2r   r   r   
test_itemsY   s    

zTestMapping.test_items)	r   r   r   r   r   r7   r9   r;   __classcell__r   r   r1   r   r'   @   s
   r'   c                   @   s^   e Zd ZdZeded Zdd Zdd Zdd	 Zd
d Z	dd Z
ee ddd ZdS )TestReprz7
        repr() works correctly with Unicode names
          c                 C   s   |  t|t d S r   )r4   r5   r6   )r   objr   r   r   _check_typeh   s    zTestRepr._check_typec                 C   s   | j | j}| | dS )z Group repr() with unicode N)r   r   USTRINGrA   r   r   r   r   
test_groupk   s    zTestRepr.test_groupc                 C   s   | j | jd}| | dS )z Dataset repr() with unicode )r   N)r   Zcreate_datasetrB   rA   )r   Zdsetr   r   r   test_datasetp   s    zTestRepr.test_datasetc                 C   s(   t d| jd< | jd }| | dS )z  Named type repr() with unicode r   typeN)npdtyper   rA   )r   typr   r   r   test_namedtypeu   s    
zTestRepr.test_namedtypec                 C   s*   t dd}| t dd| | | d S )Nr   )rG   i)r   ZassertNotEqualrA   r/   r   r   r   
test_empty{   s    
zTestRepr.test_emptyz#Filesystem unicode support requiredc                 C   s`   t | jd }z$t|d}| | W 5 Q R X W 5 zt| W n tk
rX   Y nX X dS )z! File object repr() with unicode z.hdf5r   N)tempfiler   rB   osunlink	Exceptionr   rA   )r   fnamer   r   r   r   	test_file   s    zTestRepr.test_fileN)r   r   r   r   chrrB   rA   rC   rD   rI   rK   r   ZskipIfr   rQ   r   r   r   r   r=   `   s   r=   c                  C   s4   t t dj} t| stt } t| r0td S r
   )r   rL   r   filenamer   AssertionError)rS   r   r   r   test_is_hdf5   s    rU   )r   Zh5pyr   Zh5py._hl.baser   r   commonr   r   r   numpyrF   rM   rL   r	   r   r    r'   r=   rU   r   r   r   r   <module>
   s   
 -