B
    d                 @   s   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	 ddl
mZmZ ddl
mZmZmZ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)
direct_vfd   )utTestCase)r   r   UNICODE_FILENAMESclosed_tempfilec               @   s0   e Zd Zdd Zdd Zeeddd ZdS )	
TestFileIDc          	   C   s4   t ddddd}t|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   E/var/www/html/venv/lib/python3.7/site-packages/h5py/tests/test_h5f.pytest_descriptor_core   s    zTestFileID.test_descriptor_corec          	   C   sh   t d}tj|d}z>t|ddd&}|j }| |d t	| W d Q R X W d t
| X d S )Nz5h5py.lowtest.test_h5f.TestFileID.test_descriptor_sec2ztest.h5Zsec2r   )r   r   r   )tempfilemkdtempospathjoinr   r   r   assertNotEqualfsyncshutilrmtree)r   dn_tmpfn_h5r   
descriptorr   r   r   test_descriptor_sec2   s    

zTestFileID.test_descriptor_sec2zODIRECT driver is supported on Linux if hdf5 is built with the appriorate flags.c          	   C   sh   t d}tj|d}z>t|ddd&}|j }| |d t	| W d Q R X W d t
| X d S )Nz7h5py.lowtest.test_h5f.TestFileID.test_descriptor_directztest.h5directr   )r   r   r   )r   r   r   r   r   r   r   r   r   r   r    r!   )r   r"   r#   r   r$   r   r   r   test_descriptor_direct&   s    

z!TestFileID.test_descriptor_directN)	__name__
__module____qualname__r   r%   r   Z
skipUnlessr   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 d}tj|d}z0t|dd}|j }|j }W d Q R X W d t	
| 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_gets6   s    

z TestCacheConfig.test_simple_getsc          	   C   sp   t d}tj|d}zFt|dd0}|j }|j  |j }|dksRt	W d Q R X W d t
| 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_resetA   s    



z"TestCacheConfig.test_hitrate_resetc          	   C   s\   t d}tj|d}z2t|dd}|j }|j| W d Q R X W d t	
| 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_getN   s    

z#TestCacheConfig.test_mdc_config_getN)r(   r)   r*   r/   r0   r2   r   r   r   r   r+   5   s   r+   c               @   s   e Zd Zdd ZdS )TestVlenDatac          	   C   s   t d}tj|d}zt|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  dddgkst|d  ddddgkstW d Q R X W d t| 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   strZcreate_datasetnparraytolistr   r    r!   )r   r"   r#   hZvlen_strZvlen_vlen_strZdsr   r   r   test_vlen_stringsZ   s    


$*zTestVlenData.test_vlen_stringsN)r(   r)   r*   rJ   r   r   r   r   r3   Y   s   r3   )r   r    r   numpyrF   Zh5pyr   r   Zh5py._hl.filesr   commonr   r   r   r	   r
   r+   r3   r   r   r   r   <module>
   s    $