File: test_subgraph.py

package info (click to toggle)
python-pygraphviz 1.3~rc2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 612 kB
  • ctags: 972
  • sloc: ansic: 4,964; python: 2,458; makefile: 125
file content (36 lines) | stat: -rw-r--r-- 767 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
from nose.tools import *
import pygraphviz as pgv
from os import linesep

def test_subgraph_cluster():
    G = pgv.AGraph(label='foo')
    s = G.subgraph('cluster_a', label='<Hello<BR/>World>')
    s.add_node('sa')
    G.add_node('a')
    assert_equal(G.string().expandtabs(2),
"""strict graph {
  graph [label=foo];
  {
    graph [label=<Hello<BR/>World>];
    sa;
  }
  a;
}
""".replace('\n', linesep))

def test_subgraph_cluster_attribute():
    G = pgv.AGraph()
    s = G.subgraph(name='cluster_a')
    s.node_attr['foo']='bar'
    G.add_node('a')
    G.node_attr['foo']='baz'
    assert_equal(G.string().expandtabs(2),
"""strict graph {
  node [foo=baz];
  subgraph cluster_a {
    graph [foo=bar];
  }
  a;
}
""".replace('\n', linesep))