ó
 ,µ[c           @   sÐ   d  Z  y< y d d l m Z Wn! e k
 r@ d d l m Z n XWn! e k
 re d d l m Z n Xd d l Z d d l Z d d l m Z m	 Z	 m
 Z
 d d l Z d d l m Z d e f d „  ƒ  YZ d S(   s'   Unit tests for pydot drawing functions.iÿÿÿÿ(   t   StringION(   t   assert_equalt   assert_is_instancet   assert_true(   t   assert_graphs_equalt	   TestPydotc           B   s;   e  Z e d  „  ƒ Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s/   t  j j t j t ƒ a t d k	 s+ t ‚ d S(   sœ   
        Fixture defining the `pydot` global to be the `pydot` module if both
        importable and of sufficient version _or_ skipping this test.
        N(	   t   nxt   nx_pydott   setup_modulet   syst   modulest   __name__t   pydott   Nonet   AssertionError(   t   cls(    (    s@   lib/python2.7/site-packages/networkx/drawing/tests/test_pydot.pyt
   setupClass   s    c         C   sð  d | j  d <| j d d d d g ƒ | j d ƒ t j j | d | ƒ} t | t ƒ t j j | ƒ } | j	 t j j
 | ƒ ƒ } t | | ƒ t j ƒ  } | j | ƒ t j d	 | d
 d ƒ } t t | ƒ d ƒ | d } t g  | j ƒ  D] }	 |	 j ƒ  ^ qð ƒ }
 t g  | j ƒ  D] }	 |	 j ƒ  ^ qƒ } t |
 | ƒ t g  | j ƒ  D] } | j ƒ  | j ƒ  f ^ qSƒ } t g  | j ƒ  D] } | j ƒ  | j ƒ  f ^ qŠƒ } t | | ƒ t j j | ƒ } | j	 | ƒ } t | | ƒ d S(   s©   
        Validate :mod:`pydot`-based usage of the passed NetworkX graph with the
        passed basename of an external GraphViz command (e.g., `dot`, `neato`).
        t   Gt   namet   At   Bt   Ct   Dt   Et   progt   patht   encodings   utf-8i   i    N(   R   R   (   R   R   (   R   R   (   R   R   (   t   grapht   add_edges_fromt   add_nodeR   R   t   pydot_layoutR   t   dictt   to_pydott	   __class__t
   from_pydotR   t   tempfilet   mktempt	   write_rawR   t   graph_from_dot_fileR   t   lent   sortedt   get_node_listt   get_namet   get_edge_listt
   get_sourcet   get_destinationt   read_dot(   t   selfR   R   t   graph_layoutt   Pt   G2t   fnamet   Pin_listt   Pint   pt   n1t   n2t   et   e1t   e2t   Hin(    (    s@   lib/python2.7/site-packages/networkx/drawing/tests/test_pydot.pyt   pydot_checks   s0    
++44c         C   s   |  j  t j ƒ  d d ƒd  S(   NR   t   neato(   R=   R   t   Graph(   R/   (    (    s@   lib/python2.7/site-packages/networkx/drawing/tests/test_pydot.pyt   test_undirected^   s    c         C   s   |  j  t j ƒ  d d ƒd  S(   NR   t   dot(   R=   R   t   DiGraph(   R/   (    (    s@   lib/python2.7/site-packages/networkx/drawing/tests/test_pydot.pyt   test_directeda   s    c         C   s{   t  j ƒ  } d | j d <| j d d d d ƒt ƒ  } t  j j | | ƒ | j d ƒ t  j j | ƒ } t	 | | ƒ d  S(   NR   R   t   1t   2t   keyt   0i    (
   R   t
   MultiGraphR   t   add_edgeR    R   t	   write_dott   seekR.   R   (   R/   R   t   fht   H(    (    s@   lib/python2.7/site-packages/networkx/drawing/tests/test_pydot.pyt   test_read_writed   s    	(   R   t
   __module__t   classmethodR   R=   R@   RC   RN   (    (    (    s@   lib/python2.7/site-packages/networkx/drawing/tests/test_pydot.pyR      s
   
	C		(   t   __doc__t	   cStringIOR    t   ImportErrort   ioR	   R#   t
   nose.toolsR   R   R   t   networkxR   t   networkx.testingR   t   objectR   (    (    (    s@   lib/python2.7/site-packages/networkx/drawing/tests/test_pydot.pyt   <module>   s   