U
    ½mœdÇ  ã                   @   s8   d Z ddlZddlZdd„ Zdd„ Zdd„ Zd	d
„ ZdS )z!
    Tests the h5py.File object.
é    Nc              	   C   s@   t  | d¡�*}z|d j}W n tk
r0   Y nX W 5 Q R X dS )z)Create a file and access not existing keyÚwÚdoesnt_existN)Úh5pyÚFileÚvalueÚKeyError)ÚfilenameÚnewfiler   © r
   úO/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/h5py/tests/test_errors.pyÚ_access_not_existing_object   s
    r   c                 C   s€   | d }z:t j ¡  t|ƒ | ¡ }|jdks2t‚|jdks@t‚W 5 t j ¡  X t|ƒ | ¡ }|jdksnt‚|jdks|t‚dS )z5Check that HDF5 errors can be muted/unmuted from h5pyútest.h5Ú N)	r   Ú_errorsZsilence_errorsZunsilence_errorsr   Ú
readouterrÚerrÚAssertionErrorÚout)Útmp_pathÚcapfdr   Úcapturedr
   r
   r   Útest_unsilence_errors   s    
r   c                 C   sL   t jt| d fd�}| ¡  | ¡  | ¡ }|jdks:t‚|jdksHt‚dS )zyVerify the error printing is squashed in all threads.

    No console messages should be shown from membership tests
    r   )ÚtargetÚargsr   N)	Ú	threadingÚThreadr   ÚstartÚjoinr   r   r   r   )r   r   Úthr   r
   r
   r   Ú)test_thread_hdf5_silence_error_membership2   s    ÿr   c                    sP   ‡ fdd„}t j|d�}| ¡  | ¡  | ¡ }|jdks>t‚|jdksLt‚dS )zVerify the error printing is squashed in all threads.

    No console messages should be shown for non-existing attributes
    c               	      sV   t  ˆ d d¡�<} dddg| d< z| d jd }W n tk
rF   Y nX W 5 Q R X d S )Nr   r   é   é   é   ÚnewdataÚnonexistent_attr)r   r   Úattrsr   )r	   r$   ©r   r
   r   ÚtestF   s    z1test_thread_hdf5_silence_error_attr.<locals>.test)r   r   N)r   r   r   r   r   r   r   r   )r   r   r'   r   r   r
   r&   r   Ú#test_thread_hdf5_silence_error_attrA   s    r(   )Ú__doc__r   r   r   r   r   r(   r
   r
   r
   r   Ú<module>
   s   	