U
    md                     @   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 5 Q R X d S )NTestFileID.test_descriptor_corecoreFx)driverZbacking_storemode)r   
isinstanceidget_vfd_handleintAssertionError)selff r   L/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/h5py/tests/test_h5f.pytest_descriptor_core   s     r   c              	   C   sh   t d}tj|d}z>t|ddd&}|j	 }| 
|d t| W 5 Q R X W 5 t| X d S )Nz5h5py.lowtest.test_h5f.TestFileID.test_descriptor_sec2test.h5Zsec2r   r   r   r   tempfilemkdtempospathjoinshutilrmtreer   r   r   ZassertNotEqualfsyncr   dn_tmpfn_h5r   Z
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 5 Q R X W 5 t| X d S )Nz7h5py.lowtest.test_h5f.TestFileID.test_descriptor_directr   directr   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 5 Q R X W 5 t| X d S )NzAh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_simple_getsr   r   r   )r   r   r   r    r!   r"   r#   r   _idget_mdc_hit_rateZget_mdc_size)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 5 Q R X W 5 t| X d S )NzCh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_hitrate_resetr   r   r/   r   )r   r   r   r    r!   r"   r#   r   r0   r1   Zreset_mdc_hit_rate_statsr   )r   r&   r'   r   r2   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 5 Q R X W 5 t| X d S )NzDh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_mdc_config_getr   r   r/   )r   r   r   r    r!   r"   r#   r   r0   Zget_mdc_configZset_mdc_config)r   r&   r'   r   confr   r   r   test_mdc_config_getN   s    

z#TestCacheConfig.test_mdc_config_getN)r+   r,   r-   r3   r4   r6   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 5 Q R X t|dD}|d }|d  dddgkst|d  ddddgkstW 5 Q R X W 5 t| X d S )Nz7h5py.lowtest.test_h5f.TestVlenStrings.test_vlen_stringsr   wr/   )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   r   strZcreate_datasetnparraytolistr   )r   r&   r'   hZvlen_strZvlen_vlen_strZdsr   r   r   test_vlen_stringsZ   s    


$*zTestVlenData.test_vlen_stringsN)r+   r,   r-   rN   r   r   r   r   r7   Y   s   r7   )r   r"   r   numpyrJ   Zh5pyr   r   Zh5py._hl.filesr   commonr   r   r   r	   r
   r.   r7   r   r   r   r   <module>
   s    $