3
Md                 @   sP   d Z ddlmZ ddlZddlZddlmZ ddlZej	dZ
G dd dZdS )z'Unit tests for pydot drawing functions.    )StringION)assert_graphs_equalpydotc               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
	TestPydotc             C   s:  d|j d< |jddddg |jd tjj||d}t|tsDttjj	|}|j
tjj|}t|| tj }|j| tj|d	d
}t|dkst|d }tdd |j D }	tdd |j D }
|	|
ksttdd |j D }tdd |j D }||ksttjj|}|j
|}t|| dS )z
        Validate :mod:`pydot`-based usage of the passed NetworkX graph with the
        passed basename of an external GraphViz command (e.g., `dot`, `neato`).
        GnameABCDE)progzutf-8)pathencoding   r   c             S   s   g | ]}|j  qS  )get_name).0pr   r   S/var/www/html/virt/lib/python3.6/site-packages/networkx/drawing/tests/test_pydot.py
<listcomp>6   s    z*TestPydot.pydot_checks.<locals>.<listcomp>c             S   s   g | ]}|j  qS r   )r   )r   r   r   r   r   r   9   s    c             S   s   g | ]}|j  |j fqS r   )
get_sourceget_destination)r   er   r   r   r   ?   s    c             S   s   g | ]}|j  |j fqS r   )r   r   )r   r   r   r   r   r   C   s    N)r   r	   )r   r
   )r	   r
   )r   r   )graphZadd_edges_fromadd_nodenxnx_pydotZpydot_layout
isinstancedictAssertionErrorZto_pydot	__class__Z
from_pydotr   tempfilemktempZ	write_rawr   Zgraph_from_dot_filelensortedZget_node_listZget_edge_listread_dot)selfr   r   Zgraph_layoutPZG2fnameZPin_listZPinZn1Zn2e1e2ZHinr   r   r   pydot_checks   s.    




zTestPydot.pydot_checksc             C   s   | j tj dd d S )NZneato)r   )r,   r   ZGraph)r'   r   r   r   test_undirectedP   s    zTestPydot.test_undirectedc             C   s   | j tj dd d S )Ndot)r   )r,   r   ZDiGraph)r'   r   r   r   test_directedS   s    zTestPydot.test_directedc             C   sZ   t j }d|jd< |jdddd t }t jj|| |jd t jj|}t	|| d S )Nr   r   120)keyr   )
r   Z
MultiGraphr   Zadd_edger   r   Z	write_dotseekr&   r   )r'   r   fhHr   r   r   test_read_writeV   s    

zTestPydot.test_read_writeN)__name__
__module____qualname__r,   r-   r/   r7   r   r   r   r   r      s   Cr   )__doc__ior   r"   Znetworkxr   Znetworkx.testingr   ZpytestZimportorskipr   r   r   r   r   r   <module>   s   
