File: test_repr_mimebundle.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 (25 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (2)
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
import pygraphviz as pgv
import pytest


def test_repr_output():
    A = pgv.AGraph()
    A.add_path([1, 2, 3, 4])
    assert repr(A).startswith("<AGraph <Swig Object of type 'Agraph_t")
    A.layout()
    assert A._svg_repr().startswith("<?xml version=")


def test_mimetype_select():
    A = pgv.AGraph()
    A.add_path([1, 2, 3, 4])
    assert "text/plain" in A._repr_mimebundle_()
    assert "image/svg+xml" not in A._repr_mimebundle_()
    A.layout()
    assert "image/svg+xml" in A._repr_mimebundle_()


def test_svg_repr_error():
    with pytest.raises(AttributeError):
        A = pgv.AGraph()
        A._svg_repr()