3
½ìœ]×P  ã               @   s  d Z ddlmZmZ ddlZddlZddlZddlmZ ddl	Z	ddl
mZ ddlmZmZmZmZ ddlmZ dd	lmZ ddlZyddlZW n ek
r¨   dZY nX ejƒ jZG d
d„ deƒZG dd„ deƒZG dd„ deƒZejejjd2k dƒG dd„ deƒƒZej ejjd3k dƒG dd„ deƒƒZ!G dd„ deƒZ"G dd„ deƒZ#ej e dƒG dd„ deƒƒZ$G dd „ d eƒZ%G d!d"„ d"eƒZ&G d#d$„ d$eƒZ'G d%d&„ d&eƒZ(G d'd(„ d(eƒZ)G d)d*„ d*eƒZ*G d+d,„ d,eƒZ+ej edkd-ƒG d.d/„ d/eƒƒZ,G d0d1„ d1eƒZ-dS )4z`
    File object test module.

    Tests all aspects of File objects, including their creation.
é    )Úabsolute_importÚwith_statementN)Úplatform)ÚcPickleé   )ÚutÚTestCaseÚUNICODE_FILENAMESÚclosed_tempfile)ÚFile)ÚH5pyDeprecationWarningc               @   sP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚTestFileOpenz=
        Feature: Opening files with Python-style modes.
    c          9   C   s(  | j ƒ }tjtƒ�2 t|ƒ�}| j|ƒ | j|jdƒ W dQ R X W dQ R X tj	|t
jƒ tj
|ƒjdkrttdkrtdnd}zFtjtƒ�2 t|ƒ�}| j|ƒ | j|j|ƒ W dQ R X W dQ R X W dtj	|t
jƒ X t|dƒ�}|jdƒ W dQ R X tjtƒ�$ | jtƒ� t|ƒ W dQ R X W dQ R X dS )z8 Default semantics in the presence or absence of a file zr+Nr   Úwin32ÚrÚwbó    )ÚmktempÚpytestÚwarnsr   r   Ú
assertTrueÚassertEqualÚmodeÚosÚchmodÚstatÚS_IREADÚst_uidr   ÚS_IWRITEÚopenÚwriteÚassertRaisesÚIOError)ÚselfÚfnameÚfZexp_mode© r%   ú4/tmp/pip-build-pcqn41bp/h5py/h5py/tests/test_file.pyÚtest_default.   s$    

" 

&zTestFileOpen.test_defaultc             C   sP   | j ƒ }t|dƒ}| j|ƒ |jdƒ |jƒ  t|dƒ}| jd|ƒ |jƒ  dS )z' Mode 'w' opens file in overwrite mode ÚwÚfooN)r   r   r   Úcreate_groupÚcloseZassertNotIn)r"   r#   Úfidr%   r%   r&   Útest_createM   s    



zTestFileOpen.test_createc          
   C   sH   | j ƒ }t|dƒ}| j|ƒ |jƒ  | jtƒ� t|dƒ W dQ R X dS )z( Mode 'w-' opens file in exclusive mode zw-N)r   r   r   r+   r    r!   )r"   r#   r,   r%   r%   r&   Útest_create_exclusiveX   s    

z"TestFileOpen.test_create_exclusivec             C   s‚   | j ƒ }t|dƒ}z$| j|ƒ |jdƒ d|ks4t‚W d|jƒ  X t|dƒ}z&d|ksZt‚|jdƒ d|kspt‚W d|jƒ  X dS )zE Mode 'a' opens file in append/readwrite mode, creating if necessary Úar)   NÚbar)r   r   r   r*   ÚAssertionErrorr+   )r"   r#   r,   r%   r%   r&   Útest_appenda   s    





zTestFileOpen.test_appendc          	   C   sd   | j ƒ }t|dƒ}|jƒ  | j|ƒ t|dƒ}| j|ƒ | jtƒ� |jdƒ W dQ R X |jƒ  dS )z& Mode 'r' opens file in readonly mode r(   r   r)   N)r   r   r+   ÚassertFalser   r    Ú
ValueErrorr*   )r"   r#   r,   r%   r%   r&   Útest_readonlys   s    



zTestFileOpen.test_readonlyc             C   s\   | j ƒ }t|dƒ}|jdƒ |jƒ  t|dƒ}d|ks:t‚|jdƒ d|ksPt‚|jƒ  dS )z1 Mode 'r+' opens existing file in readwrite mode r(   r)   zr+r0   N)r   r   r*   r+   r1   )r"   r#   r,   r%   r%   r&   Útest_readwrite   s    



zTestFileOpen.test_readwritec             C   sL   | j ƒ }| jtƒ� t|dƒ W dQ R X | jtƒ� t|dƒ W dQ R X dS )z( Modes 'r' and 'r+' do not create files r   Nzr+)r   r    r!   r   )r"   r#   r%   r%   r&   Útest_nonexistent_file‹   s
    z"TestFileOpen.test_nonexistent_filec          
   C   s(   | j tƒ� t| jƒ dƒ W dQ R X dS )z  Invalid modes raise ValueError ZmongooseN)r    r4   r   r   )r"   r%   r%   r&   Útest_invalid_mode“   s    zTestFileOpen.test_invalid_modeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r'   r-   r.   r2   r5   r6   r7   r8   r%   r%   r%   r&   r   (   s   	r   c               @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú	TestModesz?
        Feature: File mode can be retrieved via file.mode
    c             C   sT   | j ƒ }t|dƒ�}| j|jdƒ W dQ R X t|dƒ�}| j|jdƒ W dQ R X dS )z/ Mode equivalent can be retrieved via property r(   zr+Nr   )r   r   r   r   )r"   r#   r$   r%   r%   r&   Útest_mode_attrŸ   s
    zTestModes.test_mode_attrc             C   sª   | j ƒ }| j ƒ }t|dƒ}|jƒ  t|dƒ}z,tj|dƒ|d< |d j}| j|jdƒ W d|jƒ  |jƒ  X t|dƒ}z|d j}| j|jdƒ W d|jƒ  |jƒ  X dS )zU Mode property works for files opened via external links

        Issue 190.
        r(   ú/ZExternalzr+Nr   )r   r   r+   Úh5pyZExternalLinkÚfiler   r   )r"   Zfname1Zfname2Úf1Úf2Zf3r%   r%   r&   Útest_mode_external§   s"    





zTestModes.test_mode_externalN)r9   r:   r;   r<   r>   rD   r%   r%   r%   r&   r=   ™   s   r=   c               @   s    e Zd ZdZejejdkdƒdd„ ƒZejejdkdƒdd„ ƒZ	d	d
„ Z
dd„ Zdd„ Zdd„ Zejedƒdd„ ƒZejedƒejejjdk dƒdd„ ƒƒZdS )ÚTestDriverszF
        Feature: Files can be opened with low-level HDF5 drivers
    Úposixz"Stdio driver is supported on posixc             C   s6   t | jƒ ddd�}| j|ƒ | j|jdƒ |jƒ  dS )z$ Stdio driver is supported on posix r(   Zstdio)ÚdriverN)r   r   r   r   rG   r+   )r"   r,   r%   r%   r&   Ú
test_stdioÊ   s    
zTestDrivers.test_stdioz!Sec2 driver is supported on posixc             C   s6   t | jƒ ddd�}| j|ƒ | j|jdƒ |jƒ  dS )z# Sec2 driver is supported on posix r(   Zsec2)rG   N)r   r   r   r   rG   r+   )r"   r,   r%   r%   r&   Ú	test_sec2Ò   s    
zTestDrivers.test_sec2c             C   sN   | j ƒ }t|dddd�}| j|ƒ | j|jdƒ |jƒ  | jtjj	|ƒƒ dS )z- Core driver is supported (no backing store) r(   ÚcoreF)rG   Úbacking_storeN)
r   r   r   r   rG   r+   r3   r   ÚpathÚexists)r"   r#   r,   r%   r%   r&   Ú	test_coreÚ   s    
zTestDrivers.test_corec             C   sL   | j ƒ }t|dddd�}|jdƒ |jƒ  t|dƒ}d|ks@t‚|jƒ  dS )z3 Core driver saves to file when backing store used r(   rJ   T)rG   rK   r)   r   N)r   r   r*   r+   r1   )r"   r#   r,   r%   r%   r&   Útest_backingã   s    

zTestDrivers.test_backingc          	   C   st   | j ƒ }t|dƒ}|jdƒ |jƒ  t|ddd�}| j|ƒ d|ksHt‚| jtƒ� |jdƒ W dQ R X |jƒ  dS )z0 Core driver can be used to open existing files r(   r)   r   rJ   )rG   r0   N)r   r   r*   r+   r   r1   r    r4   )r"   r#   r,   r%   r%   r&   r5   í   s    


zTestDrivers.test_readonlyc             C   s0   | j ƒ }t|ddddd�}| j|ƒ |jƒ  dS )z* Core driver supports variable block size r(   rJ   i   F)rG   Ú
block_sizerK   N)r   r   r   r+   )r"   r#   r,   r%   r%   r&   Útest_blocksizeú   s
    

zTestDrivers.test_blocksizez.Parallel HDF5 is required for MPIO driver testc          
   C   sT   ddl m} |j}| j|ƒ}t|dd|d��}| j|ƒ | j|jdƒ W dQ R X dS )z MPIO driver and options r   )ÚMPIr(   Úmpio)rG   ÚcommN)Úmpi4pyrR   Ú
COMM_WORLDÚ
mktemp_mpir   r   r   rG   )r"   rR   rT   r#   r$   r%   r%   r&   Ú	test_mpio  s    

zTestDrivers.test_mpiozParallel HDF5 requiredr   é   é	   z5mpio atomic file operations were added in HDF5 1.8.9+c          	   C   sZ   ddl m} |j}| j|ƒ}t|dd|d��$}| j|jƒ d|_| j|jƒ W dQ R X dS )z$ Enable atomic mode for MPIO driver r   )rR   r(   rS   )rG   rT   TN)rU   rR   rV   rW   r   r3   Zatomicr   )r"   rR   rT   r#   r$   r%   r%   r&   Útest_mpi_atomic  s    
zTestDrivers.test_mpi_atomicN)r   rY   rZ   )r9   r:   r;   r<   r   Ú
skipUnlessr   ÚnamerH   rI   rN   rO   r5   rQ   ÚmpirX   ÚskipIfr@   ÚversionÚhdf5_version_tupler[   r%   r%   r%   r&   rE   Ä   s   	

rE   é
   é   zRequires HDF5 before 1.10.2c               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú
TestLibverze
        Feature: File format compatibility bounds can be specified when
        opening a file.
    c             C   s(   t | jƒ dƒ}| j|jdƒ |jƒ  dS )z Opening with no libver arg r(   ÚearliestÚlatestN)re   rf   )r   r   r   Úlibverr+   )r"   r$   r%   r%   r&   r'   '  s    zTestLibver.test_defaultc             C   s,   t | jƒ ddd�}| j|jdƒ |jƒ  dS )z  Opening with single libver arg r(   rf   )rg   N)rf   rf   )r   r   r   rg   r+   )r"   r$   r%   r%   r&   Útest_single-  s    zTestLibver.test_singlec             C   s,   t | jƒ ddd�}| j|jdƒ |jƒ  dS )z Opening with two libver args r(   re   rf   )rg   N)re   rf   )re   rf   )r   r   r   rg   r+   )r"   r$   r%   r%   r&   Útest_multiple3  s    zTestLibver.test_multiplec             C   s(   t | jƒ dƒ}| j|jdƒ |jƒ  dS )z6 Omitting libver arg results in maximum compatibility r(   re   rf   N)re   rf   )r   r   r   rg   r+   )r"   r$   r%   r%   r&   Ú	test_none9  s    zTestLibver.test_noneN)r9   r:   r;   r<   r'   rh   ri   rj   r%   r%   r%   r&   rd     s
   rd   zRequires HDF5 1.10.2 or laterc                   sT   e Zd ZdZe‡ fdd„ƒZdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Z‡  ZS )ÚTestNewLibverz�
        Feature: File format compatibility bounds can be specified when
        opening a file.

        Requirement: HDF5 1.10.2 or later
    c                s   t t| ƒjƒ  d| _d S )NÚv110)Úsuperrk   Ú
setUpClassrf   )Úcls)Ú	__class__r%   r&   rn   K  s    zTestNewLibver.setUpClassc             C   s.   t | jƒ dƒ}| j|jd| jfƒ |jƒ  dS )z Opening with no libver arg r(   re   N)r   r   r   rg   rf   r+   )r"   r$   r%   r%   r&   r'   R  s    zTestNewLibver.test_defaultc             C   s4   t | jƒ ddd�}| j|j| j| jfƒ |jƒ  dS )z  Opening with single libver arg r(   rf   )rg   N)r   r   r   rg   rf   r+   )r"   r$   r%   r%   r&   rh   X  s    zTestNewLibver.test_singlec             C   s2   t | jƒ ddd�}| j|jd| jfƒ |jƒ  dS )z  Opening with "v108" libver arg r(   Úv108)rg   N)r   r   r   rg   rf   r+   )r"   r$   r%   r%   r&   Útest_single_v108^  s    zTestNewLibver.test_single_v108c             C   s2   t | jƒ ddd�}| j|jd| jfƒ |jƒ  dS )z  Opening with "v110" libver arg r(   rl   )rg   N)r   r   r   rg   rf   r+   )r"   r$   r%   r%   r&   Útest_single_v110d  s    zTestNewLibver.test_single_v110c             C   s,   t | jƒ ddd�}| j|jdƒ |jƒ  dS )z Opening with two libver args r(   re   rq   )rg   N)re   rq   )re   rq   )r   r   r   rg   r+   )r"   r$   r%   r%   r&   ri   j  s    zTestNewLibver.test_multiplec             C   s.   t | jƒ dƒ}| j|jd| jfƒ |jƒ  dS )z6 Omitting libver arg results in maximum compatibility r(   re   N)r   r   r   rg   rf   r+   )r"   r$   r%   r%   r&   rj   p  s    zTestNewLibver.test_none)r9   r:   r;   r<   Úclassmethodrn   r'   rh   rr   rs   ri   rj   Ú__classcell__r%   r%   )rp   r&   rk   @  s   	rk   c               @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚTestUserblockz;
        Feature: Files can be create with user blocks
    c             C   s”   t | jƒ ddd�}z| j|jdƒ W d|jƒ  X t | jƒ ddd�}z| j|jdƒ W d|jƒ  X t | jƒ ddd�}z| j|jdƒ W d|jƒ  X dS )zA User blocks created with w, w-, x and properties work correctly zw-i   )Úuserblock_sizeNÚxr(   )r   r   r   rw   r+   )r"   r$   r%   r%   r&   Útest_create_blocksize}  s    

z#TestUserblock.test_create_blocksizec             C   sj   | j ƒ }t|dƒ}|jƒ  | jtƒ� tj|ddd�}W dQ R X | jtƒ� tj|ddd�}W dQ R X dS )z# User block only allowed for write r(   r   i   )rw   Nzr+)r   r   r+   r    r4   r@   )r"   r]   r$   r%   r%   r&   Útest_write_only‘  s    
zTestUserblock.test_write_onlyc             C   sr   | j ƒ }t|ddd�}|jƒ  | jtƒ� t|ddd�}W dQ R X t|ddd�}z| j|jdƒ W d|jƒ  X dS )zA User block size must match that of file when opening for append r(   i   )rw   r/   i   N)r   r   r+   r    r4   r   rw   )r"   r]   r$   r%   r%   r&   Útest_match_existing�  s    z!TestUserblock.test_match_existingc             C   sx   | j ƒ }| jtƒ� t|ddd�}W dQ R X | jtƒ� t|ddd�}W dQ R X | jtƒ� t|ddd�}W dQ R X dS )z7 User block size must be a power of 2 and at least 512 r(   é€   )rw   Ni  iÿ  )r   r    r4   r   )r"   r]   r$   r%   r%   r&   Útest_power_of_two¬  s    zTestUserblock.test_power_of_twoc             C   s¬   | j ƒ }t|ddd�}|jdƒ |jƒ  t|dƒ}z|jdd ƒ W d|jƒ  X tj|dƒ}zd|ksjt‚W d|jƒ  X t|d	ƒ}z| j|j	dƒdd ƒ W d|jƒ  X dS )
z= Test that writing to a user block does not destroy the file r(   i   )rw   ZFoobarzr+bó   XNr   Úrb)
r   r   r*   r+   r   r   r@   r1   r   Úread)r"   r]   r$   Zpyfiler%   r%   r&   Útest_write_block¹  s     




zTestUserblock.test_write_blockN)	r9   r:   r;   r<   ry   rz   r{   r}   r�   r%   r%   r%   r&   rv   w  s   rv   c               @   s   e Zd ZdZdd„ ZdS )ÚTestContextManagerzC
        Feature: File objects can be used as context managers
    c          	   C   s4   t | jƒ dƒ�}| j|ƒ W dQ R X | j| ƒ dS )z- File objects can be used in with statements r(   N)r   r   r   )r"   r,   r%   r%   r&   Útest_context_managerÚ  s    z'TestContextManager.test_context_managerN)r9   r:   r;   r<   rƒ   r%   r%   r%   r&   r‚   Ô  s   r‚   z#Filesystem unicode support requiredc               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚTestUnicodez6
        Feature: Unicode filenames are supported
    c          
   C   sN   | j tjdƒd�}t|dƒ}z"| j|j|ƒ | j|jtjƒ W d|jƒ  X dS )zM Unicode filenames can be used, and retrieved properly via .filename
        i   )Úprefixr(   N)	r   ÚsixÚunichrr   r   ÚfilenameÚassertIsInstanceÚ	text_typer+   )r"   r#   r,   r%   r%   r&   Útest_unicodeè  s    
zTestUnicode.test_unicodec          
   C   s>   | j tjdƒd�}t|dƒ�}| jtjj|ƒƒ W dQ R X dS )zG Unicode filenames can be used, and seen correctly from python
        i   )r…   r(   N)r   r†   r‡   r   r   r   rL   rM   )r"   r#   r$   r%   r%   r&   Ú#test_unicode_hdf5_python_consistentó  s    z/TestUnicode.test_unicode_hdf5_python_consistentc             C   sV   | j tjdƒd�}| jtƒ� t|dƒ W dQ R X | jtƒ� t|dƒ W dQ R X dS )zV
        Modes 'r' and 'r+' do not create files even when given unicode names
        i   )r…   r   Nzr+)r   r†   r‡   r    r!   r   )r"   r#   r%   r%   r&   Útest_nonexistent_file_unicodeú  s
    z)TestUnicode.test_nonexistent_file_unicodeN)r9   r:   r;   r<   r‹   rŒ   r�   r%   r%   r%   r&   r„   á  s   r„   c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚTestFilePropertyzk
        Feature: A File object can be retrieved from any child object,
        via the .file property
    c          
   C   s<   | j ƒ }t|dƒ}z|d j}| j||ƒ W d|jƒ  X dS )z, File object can be retrieved from subgroup r(   r?   N)r   r   rA   r   r+   )r"   r#   ÚhfileÚhfile2r%   r%   r&   Útest_property  s    

zTestFileProperty.test_propertyc             C   sV   | j ƒ }t|dƒ}|jdƒ}|j}|d j}|jƒ  | j|ƒ | j|ƒ | j|ƒ dS )z8 All retrieved File objects are closed at the same time r(   r)   r?   N)r   r   r*   rA   r+   r3   )r"   r#   r�   Úgrpr�   Zhfile3r%   r%   r&   Ú
test_close  s    




zTestFileProperty.test_closec          
   C   s>   t | jƒ dƒ}z |jdƒ}| j|jj|jƒ W d|jƒ  X dS )z9 Retrieved File objects have a meaningful mode attribute r(   r)   N)r   r   r*   r   rA   r   r+   )r"   r�   r’   r%   r%   r&   Ú	test_mode"  s
    
zTestFileProperty.test_modeN)r9   r:   r;   r<   r‘   r“   r”   r%   r%   r%   r&   rŽ     s   
rŽ   c               @   s<   e Zd ZdZdd„ Zdd„ Zdd„ Zeje	dƒd	d
„ ƒZ
dS )Ú	TestClosez*
        Feature: Files can be closed
    c             C   s.   t | jƒ dƒ}| j|ƒ |jƒ  | j|ƒ dS )z Close file via .close method r(   N)r   r   r   r+   r3   )r"   r,   r%   r%   r&   r“   2  s    
zTestClose.test_closec          	   C   s:   t | jƒ dƒ}|jƒ  | jtƒ� |jdƒ W dQ R X dS )z0 Trying to modify closed file raises ValueError r(   r)   N)r   r   r+   r    r4   r*   )r"   r,   r%   r%   r&   Útest_closed_file9  s    zTestClose.test_closed_filec             C   s2   | j ƒ }tj|dƒ}|jdƒ |jƒ  |jƒ  d S )Nr(   Útest)r   r@   r   r*   r+   )r"   r#   r$   r%   r%   r&   Ú"test_close_multiple_default_driver@  s
    
z,TestClose.test_close_multiple_default_driverz.Parallel HDF5 is required for MPIO driver testc             C   sJ   ddl m} |j}| j|ƒ}t|dd|d�}|jdƒ |jƒ  |jƒ  dS )z MPIO driver and options r   )rR   r(   rS   )rG   rT   r—   N)rU   rR   rV   rW   r   r*   r+   )r"   rR   rT   r#   r$   r%   r%   r&   Útest_close_multiple_mpio_driverG  s    

z)TestClose.test_close_multiple_mpio_driverN)r9   r:   r;   r<   r“   r–   r˜   r   r\   r^   r™   r%   r%   r%   r&   r•   ,  s
   r•   c               @   s   e Zd ZdZdd„ ZdS )Ú	TestFlushz+
        Feature: Files can be flushed
    c             C   s"   t | jƒ dƒ}|jƒ  |jƒ  dS )z Flush via .flush method r(   N)r   r   Úflushr+   )r"   r,   r%   r%   r&   Ú
test_flushZ  s    zTestFlush.test_flushN)r9   r:   r;   r<   rœ   r%   r%   r%   r&   rš   T  s   rš   c               @   s   e Zd ZdZdd„ ZdS )ÚTestReprzE
        Feature: File objects provide a helpful __repr__ string
    c             C   s>   t | jƒ dƒ}| jt|ƒtjƒ |jƒ  | jt|ƒtjƒ dS )z8 __repr__ behaves itself when files are open and closed r(   N)r   r   r‰   Úreprr†   Ústring_typesr+   )r"   r,   r%   r%   r&   Ú	test_reprg  s    zTestRepr.test_reprN)r9   r:   r;   r<   r    r%   r%   r%   r&   r�   a  s   r�   c               @   s   e Zd ZdZdd„ ZdS )ÚTestFilenamezO
        Feature: The name of a File object can be retrieved via .filename
    c          
   C   sD   | j ƒ }t|dƒ}z"| j|j|ƒ | j|jtjƒ W d|jƒ  X dS )z, .filename behaves properly for string data r(   N)r   r   r   rˆ   r‰   r†   rŠ   r+   )r"   r#   r,   r%   r%   r&   Útest_filenameu  s    
zTestFilename.test_filenameN)r9   r:   r;   r<   r¢   r%   r%   r%   r&   r¡   o  s   r¡   c               @   s   e Zd ZdZdd„ ZdS )ÚTestBackwardsCompatzM
        Feature: Deprecated attributes are included to support 1.3 code
    c             C   sD   t jtƒ�0 t| jƒ dƒ�}| j|j|jƒ W dQ R X W dQ R X dS )z> File objects provide a .fid attribute aliased to the file ID r(   N)r   r   r   r   r   ZassertIsr,   Úid)r"   r�   r%   r%   r&   Útest_fid†  s    zTestBackwardsCompat.test_fidN)r9   r:   r;   r<   r¥   r%   r%   r%   r&   r£   €  s   r£   c               @   s   e Zd ZdZdd„ ZdS )Ú!TestCloseInvalidatesOpenObjectIDszO
        Ensure that closing a file invalidates object IDs, as appropriate
    c             C   sÔ   t | jƒ dƒ�X}|jdƒ}| jt|jƒƒ | jt|jƒƒ |jƒ  | jt|jƒƒ | jt|jƒƒ W dQ R X t | jƒ dƒ�P}|jdƒ}| jt|jƒƒ | jt|jƒƒ | jt|jƒƒ | jt|jƒƒ W dQ R X dS )z; Closing a file invalidates any of the file's open objects r(   r)   N)r   r   r*   r   Úboolr¤   r+   r3   )r"   rB   Zg1rC   Zg2r%   r%   r&   r“   “  s    

z,TestCloseInvalidatesOpenObjectIDs.test_closeN)r9   r:   r;   r<   r“   r%   r%   r%   r&   r¦   �  s   r¦   zpathlib module not installedc               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestPathlibSupportz6
        Check that h5py doesn't break on pathlib
    c             C   s@   t ƒ �0}tj|ƒ}t|dƒ�}| jdƒ W dQ R X W dQ R X dS )z- Check that pathlib is accepted by h5py.File r(   TN)r
   ÚpathlibÚPathr   r   )r"   r$   rL   rC   r%   r%   r&   Útest_pathlib_accepted_fileª  s    
z-TestPathlibSupport.test_pathlib_accepted_filec             C   sd   t ƒ �T}tj|ƒ}t|dƒ�}|j}W dQ R X t|dƒ�}|j}W dQ R X | j||ƒ W dQ R X dS )z1 Check that using pathlib does not affect naming r(   N)r
   r©   rª   r   rˆ   r   )r"   r$   rL   Zh5f1Zpathlib_nameZh5f2Znormal_namer%   r%   r&   Útest_pathlib_name_match±  s    
z*TestPathlibSupport.test_pathlib_name_matchN)r9   r:   r;   r<   r«   r¬   r%   r%   r%   r&   r¨   ¤  s   r¨   c               @   s   e Zd ZdZdd„ ZdS )Ú
TestPicklez%Check that h5py.File can't be pickledc             C   s>   t | jƒ dƒ�&}| jtƒ� tj|ƒ W d Q R X W d Q R X d S )Nr(   )r   r   r    Ú	TypeErrorr   Údumps)r"   rB   r%   r%   r&   Útest_dump_error½  s    zTestPickle.test_dump_errorN)r9   r:   r;   r<   r°   r%   r%   r%   r&   r­   »  s   r­   )r   rb   rc   )r   rb   rc   ).r<   Ú
__future__r   r   r   r   r   Úsysr   r†   Z	six.movesr   Úcommonr   r   r	   r
   r@   r   Zh5py.h5py_warningsr   r©   ÚImportErrorZ
get_configr^   r   r=   rE   r\   r`   ra   rd   r_   rk   rv   r‚   r„   rŽ   r•   rš   r�   r¡   r£   r¦   r¨   r­   r%   r%   r%   r&   Ú<module>   sN   

q+Z 5]#'(