File: test_clear.py

package info (click to toggle)
python-pygraphviz 1.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 732 kB
  • sloc: ansic: 5,100; python: 2,669; makefile: 57
file content (31 lines) | stat: -rw-r--r-- 880 bytes parent folder | download | duplicates (4)
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
import pygraphviz as pgv


def test_del():
    A = pgv.AGraph()
    A.add_node(1, foo="bar")
    # For some reasons after porting to Python 3 clear often cause infinite loop
    A.delete_node("1")
    assert len(A) == 0


def test_clear_node_with_attributes():
    A = pgv.AGraph()
    A.add_node(1, foo="bar")
    # For some reasons after porting to Python 3 clear often cause infinite loop
    A.clear()
    assert len(A) == 0
    assert A.nodes() == []
    assert A.node_attr.keys() in ([], ["label"])


def test_clear_graph_attributes():
    A = pgv.AGraph()
    A.add_node(1, foo="bar")
    A.graph_attr.update(landscape="true", ranksep="0.1")
    # For some reasons after porting to Python 3 clear often cause infinite loop
    A.clear()
    assert len(A) == 0
    assert A.nodes() == []
    assert A.node_attr.keys() in ([], ["label"])
    assert A.graph_attr.keys() == []