3
½ìœ]Ÿ  ã               @   s„   d Z ddlmZ ddlZddl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dS )zv
    Common high-level operations test

    Tests features common to all high-level objects, like the .name property.
é    )Úabsolute_importN)ÚFileé   )ÚutÚTestCaseÚUNICODE_FILENAMESc               @   s   e Zd Zdd„ Zdd„ ZdS )ÚBaseTestc             C   s   t | jƒ dƒ| _d S )NÚw)r   ÚmktempÚf)Úself© r   ú4/tmp/pip-build-pcqn41bp/h5py/h5py/tests/test_base.pyÚsetUp   s    zBaseTest.setUpc             C   s   | j r| j jƒ  d S )N)r   Úclose)r   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 jdƒ}| j|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               @   sZ   e Zd ZdZejdƒejdƒ Zdd„ Zdd„ Zdd	„ Z	d
d„ Z
eje dƒdd„ ƒZdS )ÚTestReprz7
        repr() works correctly with Unicode names
    éü   éß   c             C   s.   t jr| jt|ƒtƒ n| jt|ƒt jƒ d S )N)ÚsixÚPY2ZassertIsInstanceÚreprÚbytesÚ	text_type)r   Úobjr   r   r   Ú_check_type7   s    zTestRepr._check_typec             C   s   | j j| jƒ}| j|ƒ dS )z Group repr() with unicode N)r   r   ÚUSTRINGr$   )r   r   r   r   r   Ú
test_group=   s    zTestRepr.test_groupc             C   s   | j j| jdƒ}| j|ƒ dS )z Dataset repr() with unicode r   N)r   )r   Zcreate_datasetr%   r$   )r   Zdsetr   r   r   Útest_datasetB   s    zTestRepr.test_datasetc             C   s(   t jdƒ| jd< | jd }| j|ƒ dS )z  Named type repr() with unicode r   ÚtypeN)ÚnpZdtyper   r$   )r   Útypr   r   r   Útest_namedtypeG   s    
zTestRepr.test_namedtypez#Filesystem unicode support requiredc             C   s`   t j| jd ƒ}z$t|dƒ�}| j|ƒ W dQ R X W dytj|ƒ W n tk
rX   Y nX X dS )z! File object repr() with unicode z.hdf5r	   N)Útempfiler
   r%   r   r$   ÚosÚunlinkÚ	Exception)r   Úfnamer   r   r   r   Ú	test_fileM   s    zTestRepr.test_fileN)r   r   r   r   r   Úunichrr%   r$   r&   r'   r+   r   ZskipIfr   r1   r   r   r   r   r   /   s   r   )r   Ú
__future__r   r   Zh5pyr   Úcommonr   r   r   Znumpyr)   r-   r,   r   r   r   r   r   r   r   Ú<module>   s   	