o
    cd                     @   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   sJ   t ddddd}t|j tsJ W d    d S 1 sw   Y  d S )NTestFileID.test_descriptor_corecoreFx)driverZbacking_storemode)r   
isinstanceidget_vfd_handleint)selff r   3lib/python3.10/site-packages/h5py/tests/test_h5f.pytest_descriptor_core   s   "r   c              	   C      t d}tj|d}z7t|ddd}|j }| |d t	| W d    n1 s/w   Y  W t
| d S W t
| d S t
| w )Nz5h5py.lowtest.test_h5f.TestFileID.test_descriptor_sec2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_sec2zODIRECT driver is supported on Linux if hdf5 is built with the appriorate flags.c              	   C   r   )Nz7h5py.lowtest.test_h5f.TestFileID.test_descriptor_directr   Z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   s   t d}tj|d}z0t|dd}|j }|j }W d    n1 s(w   Y  W t	
| d S W t	
| d S t	
| w )NzAh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_simple_getsr   r   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   s   t d}tj|d}z;t|dd}|j }|j  |j }|dks)J W d    n1 s3w   Y  W t	
| d S W t	
| d S t	
| w )NzCh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_hitrate_resetr   r   r.   r   )r   r   r   r    r!   r   r/   r0   Zreset_mdc_hit_rate_statsr#   r$   )r   r&   r'   r   r1   r   r   r   test_hitrate_resetA   s   



z"TestCacheConfig.test_hitrate_resetc              	   C   s   t d}tj|d}z1t|dd}|j }|j| W d    n1 s)w   Y  W t	
| d S W t	
| d S t	
| w )NzDh5py.lowtest.test_h5f.TestFileID.TestCacheConfig.test_mdc_config_getr   r   r.   )r   r   r   r    r!   r   r/   Zget_mdc_configZset_mdc_configr#   r$   )r   r&   r'   r   Zconfr   r   r   test_mdc_config_getN   s   

z#TestCacheConfig.test_mdc_config_getN)r*   r+   r,   r2   r3   r4   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}zt|dd0}ttd}t|d}|jdd|d}t	j
g d	|d|d
< t	j
g d|d|d< W d    n1 sFw   Y  t|d$}|d }|d
  g dksaJ |d  g dksmJ W d    n1 sww   Y  W t| d S W t| d S t| w )Nz7h5py.lowtest.test_h5f.TestVlenStrings.test_vlen_stringsr   wr.   )Zvlenz/com)   )Zdtype)abcr   )der   gr   rZcom)   a   b   c)   d   e   f   g)r   r   r   r    r!   r   r   strZcreate_datasetnpZarraytolistr#   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   r5   Y   s    r5   )r   r#   r   ZnumpyrG   Zh5pyr   r   Zh5py._hl.filesr   commonr   r   r   r	   r
   r-   r5   r   r   r   r   <module>   s   	 $