
    j                         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e          Z G d	 d
e          Z G d de          Z G d de          Z G d de          Z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                       e Zd Zd Zd ZdS )BaseTestc                 T    t          |                                 d          | _        d S Nw)r   mktempfselfs    W/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/h5py/tests/test_base.pysetUpzBaseTest.setUp   s    dkkmmS))    c                 J    | j         r| j                                          d S d S N)r   closer   s    r   tearDownzBaseTest.tearDown   s)    6 	FLLNNNNN	 	r   N)__name__
__module____qualname__r   r    r   r   r   r      s2        * * *    r   r   c                       e Zd ZdZd ZdS )TestNamez>
        Feature: .name attribute returns the object name
    c                 p    | j                             d          }|                     |j        d           dS )z" Anonymous objects have name None N)r   create_groupassertIsnamer   grps     r   test_anonymouszTestName.test_anonymous(   s3    f!!$''ch%%%%%r   N)r   r   r   __doc__r'   r   r   r   r    r    "   s-         & & & & &r   r    c                       e Zd ZdZd Zd ZdS )
TestParentzG
        test the parent group of the high-level interface objects
    c                     | j                             d           }|                     t                    5  |j         d d d            d S # 1 swxY w Y   d S r   )r   r"   assertRaises
ValueErrorparentr%   s     r   test_object_parent_anonymousz'TestParent.test_object_parent_anonymous3   s    f!!$''z** 	 	JJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A

AAc                     t                      }| j                            |          }|                    d          }|j        j        }|                     |d|z              d S )Nfoo/)r
   r   r"   r.   r$   assertEqual)r   r$   r&   sub_grpr.   s        r   test_object_parent_namedz#TestParent.test_object_parent_named:   s]    {{f!!$''""5))$t,,,,,r   N)r   r   r   r(   r/   r5   r   r   r   r*   r*   .   s<           - - - - -r   r*   c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )TestMappingzX
        Test if the registration of Group as a
        Mapping behaves as expected
    c                     t                                                       d}| j                            d          | _        | j        j                            d|          | _        d S )N)abbarx)superr   r   r"   r&   attrscreateattr)r   data	__class__s     r   r   zTestMapping.setUpJ   sO    6&&u--FL''T22			r   c                 
   | j                                         }|                     t          |          t                     | j                                        }|                     t          |          t                     d S r   )r   keysassertIsInstancereprstrr&   )r   key_1key_2s      r   	test_keyszTestMapping.test_keysP   s^    d5kk3///d5kk3/////r   c                 
   | j                                         }|                     t          |          t                     | j                                        }|                     t          |          t                     d S r   )r   valuesrE   rF   rG   r&   )r   value_1value_2s      r   test_valueszTestMapping.test_valuesV   s`    &--//d7mmS111(//##d7mmS11111r   c                 
   | j                                         }|                     t          |          t                     | j                                        }|                     t          |          t                     d S r   )r   itemsrE   rF   rG   r&   )r   item_1item_2s      r   
test_itemszTestMapping.test_items\   s`    d6llC000!!d6llC00000r   )	r   r   r   r(   r   rJ   rO   rT   __classcell__)rB   s   @r   r7   r7   C   so         
3 3 3 3 30 0 02 2 21 1 1 1 1 1 1r   r7   c                       e Zd ZdZ ed           ed          z   Zd Zd Zd Zd Z	d Z
 ej        e d	          d
             ZdS )TestReprz7
        repr() works correctly with Unicode names
          c                 V    |                      t          |          t                     d S r   )rE   rF   rG   )r   objs     r   _check_typezTestRepr._check_typek   s$    d3ii-----r   c                     | j                             t          | j                            }|                     |           dS )z Group repr() with unicode N)r   r"   r
   USTRINGr\   r%   s     r   
test_groupzTestRepr.test_groupn   s;    f!!)DL"9"9::r   c                     | j                             t          | j                  dd          }|                     |           dS )z Dataset repr() with unicode )r   i4N)r   create_datasetr
   r^   r\   )r   dsets     r   test_datasetzTestRepr.test_datasets   s?    v$$Yt|%<%<dDIIr   c                     t          | j                  }t          j        d          | j        |<   | j        |         }|                     |           dS )z  Named type repr() with unicode r   N)r
   r^   npdtyper   r\   )r   r$   typs      r   test_namedtypezTestRepr.test_namedtypex   sI    &&x}}tfTlr   c                     t          d          }|                     t          d          |           |                     |           d S )Nr   )rg   i)r   assertNotEqualr\   )r   rA   s     r   
test_emptyzTestRepr.test_empty   sM    3E,,,d333r   z#Filesystem unicode support requiredc                 Z   t          j        | j        dz             }	 t          |d          5 }|                     |           ddd           n# 1 swxY w Y   	 t          j        |           dS # t          $ r Y dS w xY w# 	 t          j        |           w # t          $ r Y w w xY wxY w)z! File object repr() with unicode z.hdf5r   N)tempfiler   r^   r   r\   osunlink	Exception)r   fnamer   s      r   	test_filezTestRepr.test_file   s    W 455	eC $A  ###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $	%        	%       sd   B AB AB AB A2 2
B ?B B*BB*
B'$B*&B''B*N)r   r   r   r(   chrr^   r\   r_   rd   ri   rm   r   skipIfr	   rt   r   r   r   rW   rW   c   s          c$ii##d))#G. . .  
  
    
 RY$$&KLL
 
 ML
 
 
r   rW   c                      t          t          j                    d          j        } t	          |           sJ t          j                    } t	          |           rJ d S r   )r   ro   r   filenamer   )rx   s    r   test_is_hdf5ry      sW    HO%%s++4H8  Hx       r   )r(   h5pyr   h5py._hl.baser   r   commonr   r   r	   r
   numpyrf   rp   ro   r   r    r*   r7   rW   ry   r   r   r   <module>r~      sj          ( ( ( ( ( ( ( ( > > > > > > > > > > > >     				     x   	& 	& 	& 	& 	&x 	& 	& 	&- - - - - - - -*1 1 1 1 1( 1 1 1@, , , , ,x , , ,\! ! ! ! !r   