U
    :vf(                     @   s>   d dl Z d dlZd dlmZmZ d dlmZ G dd dZdS )    N)read_p2g	write_p2g)edges_equalc                   @   s0   e Zd Zedd Zdd Zdd Zdd Zd	S )
TestP2Gc                 C   sH   t jdd| _ddddddg}| j| | jd	 t | j| _d S )
Ntest)nameabr
   c)r   d)r   e)r   f)r	   r   g)nxZGraphGadd_edges_fromadd_nodeDiGraphZDG)clsr    r   E/tmp/pip-unpacked-wheel-_lngutwb/networkx/readwrite/tests/test_p2g.pysetup_class	   s
    zTestP2G.setup_classc                 C   sj   d}t |}t|}|jdks$tt|dddgks:tdd | D }t| dd	d
dgsftd S )Ns   name
3 4
a
1 2
b

c
0 2
r   r	   r
   r   c                 S   s    g | ]\}}t |t |fqS r   )str).0uvr   r   r   
<listcomp>    s     z)TestP2G.test_read_p2g.<locals>.<listcomp>)r	   r   r   )r   r	   )r   r   )ioBytesIOr   r   AssertionErrorsortededgesr   )selfsZbytesIOr   r#   r   r   r   test_read_p2g   s    

zTestP2G.test_read_p2gc                 C   sT   d}t  }t }d|_|ddg t|| |d | }||ksPt	d S )Ns   foo
3 2
1
1 
2
2 
3

foo)      )r)      r   )
r   r    r   r   r   r   r   seekreadr!   )r$   r%   fhr   rr   r   r   test_write_p2g#   s    	

zTestP2G.test_write_p2gc                 C   sZ   t  }t }d|_|ddg t|| |d t|}t	|
 |
 sVtd S )Nr'   r   r   r   )r   r    r   r   r   r   r   r+   r   r   r#   r!   )r$   r-   r   Hr   r   r   test_write_read_p2g6   s    

zTestP2G.test_write_read_p2gN)__name__
__module____qualname__classmethodr   r&   r/   r1   r   r   r   r   r      s
   
r   )	r   Znetworkxr   Znetworkx.readwrite.p2gr   r   Znetworkx.utilsr   r   r   r   r   r   <module>   s   