/usr/lib/python2.7/dist-packages/pygraphviz/tests/test_edge_attributes.py is in python-pygraphviz 1.4~rc1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from nose.tools import *
import pygraphviz as pgv
from os import linesep
def test_edge_attributes():
A = pgv.AGraph()
A.add_edge(1,2,label='test',spam='eggs')
assert_equal(A.string().expandtabs(2),
"""strict graph {
1 -- 2 [label=test,
spam=eggs];
}
""".replace('\n', linesep)
)
def test_edge_attributes2():
A = pgv.AGraph()
A.add_edge(1,2)
one = A.get_edge(1,2)
one.attr['label'] = 'test'
one.attr['spam'] = 'eggs'
assert_true('label' in one.attr)
assert_equal(one.attr['label'], 'test')
assert_equal(sorted(one.attr.keys()), ['label', 'spam'])
assert_equal(A.string().expandtabs(2),
"""strict graph {
1 -- 2 [label=test,
spam=eggs];
}
""".replace('\n', linesep)
)
one.attr['label'] = ''
one.attr['spam'] = ''
assert_equal(A.string().expandtabs(2),
"""strict graph {
1 -- 2;
}
""".replace('\n', linesep)
)
one.attr['label'] = 'test'
del one.attr['label']
assert_equal(A.string().expandtabs(2),
"""strict graph {
1 -- 2;
}
""".replace('\n', linesep)
)
def _test_anonymous_edges():
"""graph test {\n a -- b [label="edge1"];\n a -- b [label="edge2"];\n }"""
import os,tempfile
fd, fname = tempfile.mkstemp()
#os.write(d)
#os.close(fd)
#A = AGraph(fname)
assert_equal(A.string().expandtabs(2),
"""graph test {
a -- b [label=edge1];
a -- b [label=edge2];
}
""".replace('\n', linesep))
os.unlink(fname)
def test_edge_attribute_update():
A = pgv.AGraph(strict=True)
A.add_edge(1,2,label='test',spam='eggs')
A.add_edge(1,2,label='update',spam='')
assert_equal(A.string().expandtabs(2),
"""strict graph {
1 -- 2 [label=update];
}
""".replace('\n', linesep)
)
def test_edge_attribute_update_nonstrict():
A = pgv.AGraph(strict=False)
A.add_edge(1,2,label='test',spam='eggs',key='one')
A.add_edge(1,2,label='update',spam='',key='one')
assert_equal(A.string().expandtabs(2),
"""graph {
1 -- 2 [key=one,
label=update];
}
""".replace('\n', linesep)
)
|