| 1 | import cairo |
| 2 | import pytest |
| 3 | |
| 4 | |
| 5 | def test_type(): |
| 6 | assert cairo.Glyph |
| 7 | assert issubclass(cairo.Glyph, tuple) |
| 8 | |
| 9 | with pytest.raises(TypeError): |
| 10 | cairo.Glyph() |
| 11 | |
| 12 | g = cairo.Glyph(0, 0.5, 0.25) |
| 13 | assert hash(g) == hash(cairo.Glyph(0, 0.5, 0.25)) |
| 14 | assert isinstance(g, tuple) |
| 15 | assert g == (0, 0.5, 0.25) |
| 16 | assert g == cairo.Glyph(0, 0.5, 0.25) |
| 17 | assert g[1] == 0.5 |
| 18 | assert g.index == 0 |
| 19 | assert g.x == 0.5 |
| 20 | assert g.y == 0.25 |
| 21 | |
| 22 | with pytest.raises(AttributeError): |
| 23 | assert g.z |
| 24 | |
| 25 | assert repr(cairo.Glyph(0, 0, 0)) == \ |
| 26 | "cairo.Glyph(index=0, x=0.0, y=0.0)" |
| 27 | assert str(cairo.Glyph(0, 0, 0)) == \ |
| 28 | "cairo.Glyph(index=0, x=0.0, y=0.0)" |
| 29 | assert eval(repr(g)) == g |
| 30 | |
| 31 | assert cairo.Glyph.index |
| 32 | assert cairo.Glyph.x |
| 33 | assert cairo.Glyph.y |
| 34 | |
| 35 | |
| 36 | def test_context(): |
| 37 | surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10) |
| 38 | context = cairo.Context(surface) |
| 39 | assert context.glyph_extents([(0, 0, 0)]) |
| 40 | context.glyph_path([(0, 0, 0)]) |
| 41 | context.show_glyphs([(0, 0, 0)]) |
| 42 | |
| 43 | g = cairo.Glyph(0, 0.5, 0.25) |
| 44 | assert context.glyph_extents([g]) |
| 45 | context.glyph_path([g]) |
| 46 | context.show_glyphs([(0, 0, 0)]) |
| 47 | |
| 48 | with pytest.raises(TypeError): |
| 49 | context.glyph_path([object()]) |