ó
\c           @@  sF  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z m	 Z	 d d l
 Z
 d d l
 m Z d d l
 m Z m Z d d l
 m Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s×   
    Attributes testing module

    Covers all operations which access the .attrs property, with the
    exception of data read/write and type conversion.  Those operations
    are tested by module test_attrs_data.
i    (   t   absolute_importNi   (   t   TestCaset   ut(   t   File(   t   h5at   h5t(   t   AttributeManagert	   BaseAttrsc           B@  s   e  Z d  „  Z d „  Z RS(   c         C@  s   t  |  j ƒ  d ƒ |  _ d  S(   Nt   w(   R   t   mktempt   f(   t   self(    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   setUp#   s    c         C@  s   |  j  r |  j  j ƒ  n  d  S(   N(   R
   t   close(   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   tearDown&   s    	(   t   __name__t
   __module__R   R   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyR   !   s   	t
   TestAccessc           B@  s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sG   
        Feature: Attribute creation/retrieval via special methods
    c         C@  sS   d |  j  j d <|  j t |  j  j j ƒ  ƒ d g ƒ |  j |  j  j d d ƒ d S(   s)    Attribute creation by direct assignment g      @t   aN(   R
   t   attrst   assertEqualt   listt   keys(   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_create1   s    %c         C@  s>   d |  j  j d <d |  j  j d <|  j |  j  j d d ƒ d S(   s%    Attributes are silently overwritten g      @R   g      @N(   R
   R   R   (   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_overwrite7   s    c         C@  sT   d |  j  j d <|  j |  j  j d j d ƒ |  j |  j  j d t j d ƒ ƒ d S(	   s    Attribute rank is preserved g      @g      @R   i   N(   g      @g      @(   i   (   g      @g      @(   R
   R   R   t   shapet   assertArrayEqualt   npt   array(   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt	   test_rank=   s    c         C@  sT   t  j d ƒ |  j j d <|  j j d } |  j | j d ƒ |  j | d d ƒ d S(   s/    Attributes of shape (1,) don't become scalars i   R   N(   i   (   i   (    (   R   t   onesR
   R   R   R   (   R   t   out(    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_singleC   s    c         C@  s(   |  j  t ƒ  |  j j d Wd QXd S(   s0    Attempt to access missing item raises KeyError R   N(   t   assertRaisest   KeyErrorR
   R   (   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_access_excJ   s    (   R   R   t   __doc__R   R   R   R    R#   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyR   +   s   				t
   TestDeletec           B@  s    e  Z d  Z d „  Z d „  Z RS(   s?   
        Feature: Deletion of attributes using __delitem__
    c         C@  sM   d |  j  j d <|  j d |  j  j ƒ |  j  j d =|  j d |  j  j ƒ d S(   s    Deletion via "del" g      @R   N(   R
   R   t   assertInt   assertNotIn(   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_deleteV   s    c         C@  s'   |  j  t ƒ  |  j j d =Wd QXd S(   s0    Attempt to delete missing item raises KeyError R   N(   R!   R"   R
   R   (   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_delete_exc]   s    (   R   R   R$   R(   R)   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyR%   P   s   	t   TestUnicodec           B@  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sM   
        Feature: Attributes can be accessed via Unicode or byte strings
    c         C@  s4   d |  j  j d <|  j  j d } |  j | d ƒ d S(   s#    Access via pure-ASCII byte string i*   t   asciiN(   R
   R   R   (   R   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt
   test_asciii   s    c         C@  s:   d } d |  j  j | <|  j  j | } |  j | d ƒ d S(   s"    Access via non-ASCII byte string s
   non-asciiþi*   N(   R
   R   R   (   R   t   nameR   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_rawo   s    c         C@  sG   d t  j d ƒ } d |  j j | <|  j j | } |  j | d ƒ d S(   s5    Access via Unicode string with non-ascii characters u   Omegai©  i*   N(   t   sixt   unichrR
   R   R   (   R   R-   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_unicodev   s    (   R   R   R$   R,   R.   R1   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyR*   c   s   		t
   TestCreatec           B@  s   e  Z d  Z d „  Z RS(   s5   
        Options for explicit attribute creation
    c         C@  s®   t  j d ƒ |  j d <|  j j j d d d |  j d ƒ|  j |  j j d d ƒ t j |  j j d ƒ } | j	 ƒ  } |  j d j } |  j | | ƒ |  j
 | j ƒ  ƒ d S(   sL    Attributes created from named types link to the source type object
        t   u8t   typet   xi*   t   dtypeN(   R   R6   R
   R   t   createR   R   t   opent   idt   get_typet
   assertTruet	   committed(   R   t   aidt   htypet   htype2(    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt
   test_named„   s    #(   R   R   R$   R@   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyR2   ~   s   t   TestMutableMappingc           B@  s    e  Z d  Z d „  Z d „  Z RS(   s^   Tests if the registration of AttributeManager as a MutableMapping
    behaves as expected
    c         C@  s:   t  t t j ƒ s t ‚ t |  j j t j ƒ s6 t ‚ d  S(   N(   t
   issubclassR   t   collectionst   MutableMappingt   AssertionErrort
   isinstanceR
   R   (   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_resolution•   s    c         C@  s'   t  j t  j t  j t  j t  j d S(   sC   
        Test that the required functions are implemented.
        N(   R   t   __getitem__t   __setitem__t   __delitem__t   __iter__t   __len__(   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_validity™   s
    (   R   R   R$   RG   RM   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyRA   ‘   s   	t   TestVlenc           B@  s   e  Z d  „  Z RS(   c         C@  so   t  j t  j d ƒ t  j d ƒ g d t j d t ƒ ƒ} | |  j j d <|  j |  j j d d | d ƒ d  S(   Ni   i   R6   t   vlenR   i    (	   R   R   t   arangeR   t   special_dtypet   intR
   R   R   (   R   R   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt	   test_vlen¤   s    $(   R   R   RS   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyRN   £   s   t   TestTrackOrderc           B@  sA   e  Z d  „  Z e j e j j d k d ƒ d „  ƒ Z d „  Z	 RS(   c         C@  sF   |  j  j d d | ƒj } x$ t d ƒ D] } | | t | ƒ <q( W| S(   Nt   testt   track_orderid   (   R
   t   create_groupR   t   ranget   str(   R   RV   R   t   i(    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt
   fill_attrs«   s    i   i
   i   s   HDF5 1.10.5 requiredc         C@  sO   |  j  d t ƒ } |  j t | ƒ g  t d ƒ D] } d t | ƒ ^ q. ƒ d  S(   NRV   id   u    (   R[   t   TrueR   R   RX   RY   (   R   R   RZ   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_track_order±   s    c         C@  sU   |  j  d t ƒ } |  j t | ƒ t g  t d ƒ D] } d t | ƒ ^ q1 ƒ ƒ d  S(   NRV   id   u    (   R[   t   FalseR   R   t   sortedRX   RY   (   R   R   RZ   (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   test_no_track_order¸   s    (   i   i
   i   (
   R   R   R[   R   t
   skipUnlesst   h5pyt   versiont   hdf5_version_tupleR]   R`   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyRT   ª   s   	'(   R$   t
   __future__R    R/   t   numpyR   RC   t   commonR   R   Rb   R   R   R   R   R   R   R%   R*   R2   RA   RN   RT   (    (    (    s8   lib/python2.7/site-packages/h5py/tests/old/test_attrs.pyt   <module>   s"   
%