File: test_record.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (36 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download | duplicates (3)
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
import py
from dotviewer.drawgraph import TextSnippetRecordLR, record_to_nested_lists
from dotviewer.conftest import option

def test_split_record():
    s = "a|{b|c|d|e}|{f|{g|h}|{i|j}|k|l}"
    l = record_to_nested_lists(s)
    assert l == ['a', ['b', 'c', 'd', 'e'], ['f', ['g', 'h'], ['i', 'j'], 'k', 'l']]
    s = "{An Mrecord|has rounded|corners}"
    l = record_to_nested_lists(s)
    s = "a|b|c"
    l = record_to_nested_lists(s)
    assert l == s.split("|")

def test_split_record_escape():
    s = '|{(\\{process1\\}->(0->1->\\{process3\\}))\n|# states: 1}|'
    l = record_to_nested_lists(s)
    assert l == ['', ['({process1}->(0->1->{process3}))', '# states: 1'], '']

def test_html_entity():
    s = '(∅↦1↦∅)'
    l = record_to_nested_lists(s)
    assert l == [u'(\u2205\u21a61\u21a6\u2205)']

def test_ignore_angular():
    s = "a|{<portname>b|c|d|e}|{f|{g|h}|{i|j}|k|l}"
    l = record_to_nested_lists(s)
    assert l == ['a', ['b', 'c', 'd', 'e'], ['f', ['g', 'h'], ['i', 'j'], 'k', 'l']]

def test_show():
    if not option.pygame:
        py.test.skip("--pygame not enabled")
    from dotviewer.drawgraph import GraphLayout
    layout = GraphLayout(1, 2.0972, 0.97222)
    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')
    layout.display()