
    1Vh                         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e      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Zd Zy)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                       e Zd Zd Zd Zy)BaseTestc                 B    t        | j                         d      | _        y Nw)r   mktempfselfs    D/home/dcms/DCMS/lib/python3.12/site-packages/h5py/tests/test_base.pysetUpzBaseTest.setUp   s    dkkmS)    c                 R    | j                   r| j                   j                          y y N)r   closer   s    r   tearDownzBaseTest.tearDown   s    66FFLLN r   N)__name__
__module____qualname__r   r    r   r   r   r      s    *r   r   c                       e Zd ZdZd Zy)TestNamez>
        Feature: .name attribute returns the object name
    c                 r    | j                   j                  d      }| j                  |j                  d       y)z" Anonymous objects have name None N)r   create_groupassertIsnamer   grps     r   test_anonymouszTestName.test_anonymous(   s(    ff!!$'chh%r   N)r   r   r   __doc__r&   r   r   r   r   r   "   s    &r   r   c                       e Zd ZdZd Zy)
TestParentzG
        test the parent group of the high-level interface objects
    c                 N   | j                   j                  d       }| j                  t              5  |j                   d d d        | j                   j                  d      }|j                  d      }|j                  j
                  }| j                  |d       y # 1 sw Y   ^xY w)Nbarfooz/bar)r   r!   assertRaises
ValueErrorparentr#   assertEqual)r   r%   sub_grpr/   s       r   test_object_parentzTestParent.test_object_parent3   s    ff!!$'z* 	JJ	 ff!!%(""5)$$(	 	s   BB$N)r   r   r   r'   r2   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                  j                  d      | _        | j                  j
                  j                  d|      | _        y )N)abr+   x)superr   r   r!   r%   attrscreateattr)r   data	__class__s     r   r   zTestMapping.setUpG   sC    66&&u-FFLL''T2	r   c                     | j                   j                         }| j                  t        |      t               | j
                  j                         }| j                  t        |      t               y r   )r   keysassertIsInstancereprstrr%   )r   key_1key_2s      r   	test_keyszTestMapping.test_keysM   sH    d5k3/d5k3/r   c                     | j                   j                         }| j                  t        |      t               | j
                  j                         }| j                  t        |      t               y r   )r   valuesrA   rB   rC   r%   )r   value_1value_2s      r   test_valueszTestMapping.test_valuesS   sI    &&--/d7mS1((//#d7mS1r   c                     | j                   j                         }| j                  t        |      t               | j
                  j                         }| j                  t        |      t               y r   )r   itemsrA   rB   rC   r%   )r   item_1item_2s      r   
test_itemszTestMapping.test_itemsY   sI    d6lC0!d6lC0r   )	r   r   r   r'   r   rF   rK   rP   __classcell__)r>   s   @r   r4   r4   @   s    
3021r   r4   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y)TestReprz7
        repr() works correctly with Unicode names
          c                 B    | j                  t        |      t               y r   )rA   rB   rC   )r   objs     r   _check_typezTestRepr._check_typeh   s    d3i-r   c                 p    | j                   j                  | j                        }| j                  |       y)z Group repr() with unicode N)r   r!   USTRINGrX   r$   s     r   
test_groupzTestRepr.test_groupk   s(    ff!!$,,/r   c                 r    | j                   j                  | j                  d      }| j                  |       y)z Dataset repr() with unicode )r   N)r   create_datasetrZ   rX   )r   dsets     r   test_datasetzTestRepr.test_datasetp   s*    vv$$T\\48r   c                     t        j                  d      | j                  d<   | j                  d   }| j                  |       y)z  Named type repr() with unicode r   typeN)npdtyper   rX   )r   typs     r   test_namedtypezTestRepr.test_namedtypeu   s2    #vffVnr   c                 v    t        d      }| j                  t        d      |       | j                  |       y )Nr   )rc   i)r   assertNotEqualrX   )r   r=   s     r   
test_emptyzTestRepr.test_empty{   s/    3E,d3r   z#Filesystem unicode support requiredc                 L   t        j                  | j                  dz         }	 t        |d      5 }| j	                  |       ddd       	 t        j                  |       y# 1 sw Y    xY w# t        $ r Y y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   rZ   r   rX   osunlink	Exception)r   fnamer   s      r   	test_filezTestRepr.test_file   s     W 45	eC $A  #$		% 	$ $
  		%  sX   A< A!A< A- !A*&A< -	A98A9<B#>BB#	B B#B  B#N)r   r   r   r'   chrrZ   rX   r[   r_   re   ri   r   skipIfr	   rp   r   r   r   rS   rS   `   s[     $i#d)#G.


 RYY$$&KL
 M
r   rS   c                      t        t        j                         d      j                  } t	        |       sJ t        j                         } t	        |       rJ y r   )r   rk   r   filenamer   )rt   s    r   test_is_hdf5ru      sF    HOO%s+44H8 Hx    r   )r'   h5pyr   h5py._hl.baser   r   commonr   r   r	   numpyrb   rl   rk   r   r   r)   r4   rS   ru   r   r   r   <module>rz      sd     ( 3 3  	 x 	&x 	&) )&1( 1@+x +Z!r   