3
_½µ_ë  ã               @   sp   d dl Z d dlZd dlZd dlZd dlmZmZ ddlm	Z	 G dd„ de	ƒZ
G dd„ de	ƒZG d	d
„ d
e	ƒZdS )é    N)ÚFileÚspecial_dtypeé   )ÚTestCasec               @   s   e Zd Zdd„ Zdd„ ZdS )Ú
TestFileIDc          
   C   s4   t ddddd��}t|jjƒ tƒs&t‚W d Q R X d S )NzTestFileID.test_descriptor_coreÚcoreFÚx)ÚdriverZbacking_storeÚmode)r   Ú
isinstanceÚidÚget_vfd_handleÚintÚAssertionError)ÚselfÚf© r   ú5/tmp/pip-install-xpigntgx/h5py/h5py/tests/test_h5f.pyÚtest_descriptor_core   s    zTestFileID.test_descriptor_corec             C   sh   t jdƒ}tjj|dƒ}z>t|ddd��&}|jjƒ }| j|dƒ tj	|ƒ W d Q R X W d t
j|ƒ X d S )Nz5h5py.lowtest.test_h5f.TestFileID.test_descriptor_sec2ztest.h5Zsec2r   )r	   r
   r   )ÚtempfileÚmkdtempÚosÚpathÚjoinr   r   r   ZassertNotEqualÚfsyncÚshutilÚrmtree)r   Údn_tmpÚfn_h5r   Z
descriptorr   r   r   Útest_descriptor_sec2   s    

zTestFileID.test_descriptor_sec2N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s   r   c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestCacheConfigc             C   sZ   t jdƒ}tjj|dƒ}z0t|dd��}|jjƒ }|jjƒ }W d Q R X W d t	j
|ƒ X d S )NzAh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_simple_getsztest.h5r   )r
   )r   r   r   r   r   r   Ú_idÚget_mdc_hit_rateZget_mdc_sizer   r   )r   r   r   r   Úhit_rateZmdc_sizer   r   r   Útest_simple_gets&   s    

z TestCacheConfig.test_simple_getsc             C   sp   t jdƒ}tjj|dƒ}zFt|dd��0}|jjƒ }|jjƒ  |jjƒ }|dksRt	‚W d Q R X W d t
j|ƒ X d S )NzCh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_hitrate_resetztest.h5r   )r
   r   )r   r   r   r   r   r   r$   r%   Zreset_mdc_hit_rate_statsr   r   r   )r   r   r   r   r&   r   r   r   Útest_hitrate_reset1   s    



z"TestCacheConfig.test_hitrate_resetc             C   s\   t jdƒ}tjj|dƒ}z2t|dd��}|jjƒ }|jj|ƒ W d Q R X W d t	j
|ƒ X d S )NzDh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_mdc_config_getztest.h5r   )r
   )r   r   r   r   r   r   r$   Zget_mdc_configZset_mdc_configr   r   )r   r   r   r   Úconfr   r   r   Útest_mdc_config_get>   s    

z#TestCacheConfig.test_mdc_config_getN)r    r!   r"   r'   r(   r*   r   r   r   r   r#   %   s   r#   c               @   s   e Zd Zdd„ ZdS )ÚTestVlenDatac             C   sð   t jdƒ}tjj|dƒ}zÆt|dd��\}ttd�}t|d�}|jdd|d�}t	j
d	d
dg|d�|d< t	j
ddddg|d�|d< W d Q R X t|dƒ�D}|d }|d jƒ dddgks¶t‚|d jƒ ddddgksÒt‚W d Q R X W d tj|ƒ X d S )Nz7h5py.lowtest.test_h5f.TestVlenStrings.test_vlen_stringsztest.h5Úw)r
   )Zvlenz/comé   )ZdtypeÚaÚbÚcr   ÚdÚer   Úgr   ÚrÚcomó   aó   bó   có   dó   eó   fó   g)r-   )r   r   r   r   r   r   r   ÚstrZcreate_datasetÚnpÚarrayÚtolistr   r   r   )r   r   r   ÚhZvlen_strZvlen_vlen_strZdsr   r   r   Útest_vlen_stringsJ   s    


$*zTestVlenData.test_vlen_stringsN)r    r!   r"   rB   r   r   r   r   r+   I   s   r+   )r   r   r   Znumpyr>   Zh5pyr   r   Úcommonr   r   r#   r+   r   r   r   r   Ú<module>
   s   $