o
    ]Zhm                     @   s~   d Z ddlmZ ddlZddlZddlmZ edZ	G dd dZ
dd	 Zejd
ejejejejgdd Zdd ZdS )z'Unit tests for pydot drawing functions.    )StringION)graphs_equalpydotc                   @   sD   e Zd Zejde e fejdddd Z	dd Z
dS )		TestPydotGprog)Zneatodotc                 C   s<  d|j d< |g d |d tjj||d}t|ts J tj|}|	tj
|}t||s6J |d }|| tj|dd}t|d	ksNJ |d
 }	tdd | D }
tdd |	 D }|
|ksnJ tdd | D }tdd |	 D }||ksJ tj|}|	|}t||sJ 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`).
        r   name)AB)r   Cr   r   )r   DEr   zout.dotzutf-8)pathencoding   r   c                 s       | ]}|  V  qd S Nget_name.0p r   P/var/www/auris/lib/python3.10/site-packages/networkx/drawing/tests/test_pydot.py	<genexpr>:       z'TestPydot.test_pydot.<locals>.<genexpr>c                 s   r   r   r   r   r   r   r   r   =   r   c                 s        | ]}|  | fV  qd S r   
get_sourceZget_destinationr   er   r   r   r   C       c                 s   r    r   r!   r#   r   r   r   r   F   r%   N)graphadd_edges_fromadd_nodenxnx_pydotpydot_layout
isinstancedictto_pydot	__class__
from_pydotr   Z	write_rawr   Zgraph_from_dot_filelensortedZget_node_listZget_edge_listread_dot)selfr   r   tmp_pathgraph_layoutPG2fnameZPin_listZPinZn1Zn2e1e2ZHinr   r   r   
test_pydot   s,   




zTestPydot.test_pydotc                 C   s^   t  }d|jd< |jdddd t }t j|| |d t j|}t	||s-J d S )Nr   r	   120)keyr   )
r)   
MultiGraphr&   add_edger   r*   Z	write_dotseekr3   r   )r4   r   fhHr   r   r   test_read_writeR   s   

zTestPydot.test_read_writeN)__name__
__module____qualname__pytestmarkparametrizer)   GraphDiGraphr<   rF   r   r   r   r   r      s
    Br   c                 C   sd   t  }|g d t jj|dd}t|tsJ t j|}t t j|}t	||s0J dS )zValidate that `nx_pydot.pydot_layout` handles nodes
    with characters like "
", " ".

    Those characters cause `pydot` to escape and quote them on output,
    which caused #7581.
    ))
A
big testr   )rO   r   r   r   r   N)
r)   rM   r'   r*   r+   r,   r-   r.   r0   r   )r5   r   r6   r7   r8   r   r   r   test_pydot_issue_7581]   s   rP   
graph_typec                 C   s   |  }|j dtdgddd |j dddd	td
gd |j dddd dddddddddigdd tjtj|j D ksFJ dd | D t	tjtj|jks^J d S )N5r   z"Example:A"F)tlr=      T)node1rV   )wrS   rT   node)   rY   string)rW   FalseTruez
('node1',)zfrozenset({'node1'})rW   c                 S   s   g | ]\}}}|qS r   r   )r   _attrr   r   r   
<listcomp>~   s    z'test_hashable_pydot.<locals>.<listcomp>c                 S   s   h | ]}t |qS r   )str)r   ir   r   r   	<setcomp>   s    z&test_hashable_pydot.<locals>.<setcomp>)
rB   	frozensetr)   r*   r0   r.   edgesdatanodesset)rQ   r   r   r   r   test_hashable_pydotp   s   
	rh   c                  C   s   t  } | ddg t jj| dd}t|tsJ d|vs J d|v s&J d|vs,J d|v s2J d	|v s8J d
|v s>J d S )Nr
   )r   r   r   r   r?   r   r=   r   r   r   )r)   rM   r'   r*   r+   r,   r-   )r   r6   r   r   r   test_pydot_numerical_name   s   ri   )__doc__ior   rJ   Znetworkxr)   Znetworkx.utilsr   Zimportorskipr   r   rP   rK   rL   rM   rN   rA   ZMultiDiGraphrh   ri   r   r   r   r   <module>   s    
P
