o
    gi                     @   s   d Z ddlmZ ddlmZmZ ddlmZ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_FILENAMES	make_nameNc                   @   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   R/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/h5py/tests/test_base.pysetUp      zBaseTest.setUpc                 C   s   | j r
| j   d S 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_group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d ZdS )
TestParentzG
        test the parent group of the high-level interface objects
    c                 C   sB   | j d }| t |j W d    d S 1 sw   Y  d S r   )r   r   assertRaises
ValueErrorparentr   r   r   r   test_object_parent_anonymous3   s   "z'TestParent.test_object_parent_anonymousc                 C   s8   t  }| j|}|d}|jj}| |d|  d S )Nfoo/)r	   r   r   r&   r   assertEqual)r   r   r    sub_grpr&   r   r   r   test_object_parent_named:   s
   
z#TestParent.test_object_parent_namedN)r   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bbarx)superr   r   r   r    attrscreateattrr   data	__class__r   r   r   J   s   
zTestMapping.setUpc                 C   8   | j  }| t|t | j }| t|t d S r   )r   keysassertIsInstancereprstrr    )r   key_1key_2r   r   r   	test_keysP      

zTestMapping.test_keysc                 C   r:   r   )r   valuesr<   r=   r>   r    )r   value_1value_2r   r   r   test_valuesV   rB   zTestMapping.test_valuesc                 C   s8   | j  }| t|t | j }| t|t d S r   )r   itemsr<   r=   r>   r    )r   item_1item_2r   r   r   
test_items\   rB   zTestMapping.test_items)	r   r   r   r"   r   rA   rF   rJ   __classcell__r   r   r8   r   r-   C   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   )r<   r=   r>   )r   objr   r   r   _check_typek   r   zTestRepr._check_typec                 C   s    | j t| j}| | dS )z Group repr() with unicode N)r   r   r	   USTRINGrP   r   r   r   r   
test_groupn   s   zTestRepr.test_groupc                 C   s$   | j t| jdd}| | dS )z Dataset repr() with unicode )r   i4N)r   create_datasetr	   rQ   rP   )r   dsetr   r   r   test_datasets   s   zTestRepr.test_datasetc                 C   s2   t | j}td| j|< | j| }| | dS )z  Named type repr() with unicode r   N)r	   rQ   npdtyper   rP   )r   r   typr   r   r   test_namedtypex   s   

zTestRepr.test_namedtypec                 C   s*   t dd}| t dd| | | d S )Nr   )rX   i)r   assertNotEqualrP   r6   r   r   r   
test_empty   s   
zTestRepr.test_emptyz#Filesystem unicode support requiredc                 C   s   t | jd }z.t|d}| | W d   n1 sw   Y  W zt| W dS  ty6   Y dS w zt| W w  tyG   Y w w )z! File object repr() with unicode z.hdf5r   N)tempfiler   rQ   r   rP   osunlink	Exception)r   fnamer   r   r   r   	test_file   s    zTestRepr.test_fileN)r   r   r   r"   chrrQ   rP   rR   rV   rZ   r]   r   skipIfr   rc   r   r   r   r   rL   c   s    rL   c                  C   s4   t t dj} t| sJ t } t| rJ d S r   )r   r^   r   filenamer   )rf   r   r   r   test_is_hdf5   s   rg   )r"   h5pyr   h5py._hl.baser   r   commonr   r   r   r	   numpyrW   r_   r^   r
   r   r#   r-   rL   rg   r   r   r   r   <module>   s   	
 .