o
    giA	                     @   sZ   d Z ddlZddlZddlZddlmZ dd Zejjddd	d
 Z	dd Z
dd ZdS )z!
    Tests the h5py.File object.
    N   )	make_namec              	   C   sd   t | d"}z|d j}W n	 ty   Y n	w W d   dS W d   dS 1 s+w   Y  dS )z)Create a file and access not existing keywdoesnt_existN)h5pyFilevalueKeyError)filenamenewfiler    r   T/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/h5py/tests/test_errors.py_access_not_existing_object   s   "r   zChanges global state)reasonc                 C   s   | d }z"t j  t| | }|jdksJ |jdks J W t j  nt j  w t| | }|jdks<J |jdksCJ dS )z5Check that HDF5 errors can be muted/unmuted from h5pyztest.h5 N)r   _errorsunsilence_errorsr   
readouterrerroutsilence_errors)tmp_pathcapfdr
   capturedr   r   r   test_unsilence_errors   s   
r   c                 C   sP   t jt| td fd}|  |  | }|jdksJ |jdks&J dS )zyVerify the error printing is squashed in all threads.

    No console messages should be shown from membership tests
    {}.h5)targetargsr   N)		threadingThreadr   r   startjoinr   r   r   )r   r   thr   r   r   r   )test_thread_hdf5_silence_error_membership7   s   r#   c                    sP    fdd}t j|d}|  |  | }|jdksJ |jdks&J dS )zVerify the error printing is squashed in all threads.

    No console messages should be shown for non-existing attributes
    c               	      s|   t  td d*} g d| d< z	| d jd }W n	 ty#   Y n	w W d    d S W d    d S 1 s7w   Y  d S )Nr   r   )r         newdatanonexistent_attr)r   r   r   attrsr	   )r   r'   r   r   r   testK   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   #test_thread_hdf5_silence_error_attrF   s   r+   )__doc__r   pytestr   commonr   r   markthread_unsafer   r#   r+   r   r   r   r   <module>   s   		
