Debian Codegraph @

dotviewer/test/test_record.py

raw symbols SCIP
1 import py
2 from dotviewer.drawgraph import TextSnippetRecordLR, record_to_nested_lists
3 from dotviewer.conftest import option
4
5 def test_split_record():
6 s = "a|{b|c|d|e}|{f|{g|h}|{i|j}|k|l}"
7 l = record_to_nested_lists(s)
8 assert l == ['a', ['b', 'c', 'd', 'e'], ['f', ['g', 'h'], ['i', 'j'], 'k', 'l']]
9 s = "{An Mrecord|has rounded|corners}"
10 l = record_to_nested_lists(s)
11 s = "a|b|c"
12 l = record_to_nested_lists(s)
13 assert l == s.split("|")
14
15 def test_split_record_escape():
16 s = '|{(\\{process1\\}->(0->1->\\{process3\\}))\n|# states: 1}|'
17 l = record_to_nested_lists(s)
18 assert l == ['', ['({process1}->(0->1->{process3}))', '# states: 1'], '']
19
20 def test_html_entity():
21 s = '(∅↦1↦∅)'
22 l = record_to_nested_lists(s)
23 assert l == [u'(\u2205\u21a61\u21a6\u2205)']
24
25 def test_ignore_angular():
26 s = "a|{<portname>b|c|d|e}|{f|{g|h}|{i|j}|k|l}"
27 l = record_to_nested_lists(s)
28 assert l == ['a', ['b', 'c', 'd', 'e'], ['f', ['g', 'h'], ['i', 'j'], 'k', 'l']]
29
30 def test_show():
31 if not option.pygame:
32 py.test.skip("--pygame not enabled")
33 from dotviewer.drawgraph import GraphLayout
34 layout = GraphLayout(1, 2.0972, 0.97222)
35 layout.add_node('rec', 1.0486, 0.48611, 2.0972, 0.97222, "{a|b|c}|d|e|f|{{g|h}|i}", 'solid', 'record', 'black', 'lightgrey')
36 layout.display()