File: test_textcluster.py

package info (click to toggle)
pycairo 1.27.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,984 kB
  • sloc: ansic: 8,873; python: 3,688; makefile: 32; sh: 4
file content (29 lines) | stat: -rw-r--r-- 753 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
26
27
28
29
import cairo
import pytest


def test_type():
    assert cairo.TextCluster
    assert issubclass(cairo.TextCluster, tuple)

    with pytest.raises(TypeError):
        cairo.TextCluster()

    r = cairo.TextCluster(2, 1)
    assert hash(r) == hash(cairo.TextCluster(2, 1))
    assert isinstance(r, tuple)
    assert r == (2, 1)
    assert r == cairo.TextCluster(2, 1)
    assert r[1] == 1
    assert r.num_bytes == 2
    assert r.num_glyphs == 1

    with pytest.raises(AttributeError):
        assert r.z

    assert repr(r) == "cairo.TextCluster(num_bytes=2, num_glyphs=1)"
    assert str(r) == "cairo.TextCluster(num_bytes=2, num_glyphs=1)"
    assert eval(repr(r)) == r

    assert cairo.TextCluster.num_bytes
    assert cairo.TextCluster.num_glyphs