Debian Codegraph @

tests/integration/text/test_layout_creation.py

raw symbols SCIP
1 """Test creation of all Layout classes"""
2 import random
3 import itertools
4
5
6 import pytest
7
8 from pyglet.text import document
9 from pyglet.text import layout
10
11 WIDTH = 500
12 HEIGHT = 100
13 X = random.randint(0, 900)
14 Y = random.randint(0, 600)
15 Z = random.randint(-10, 10)
16
17
18 # Create combination of all Layout and Document types
19 document_classes = [document.UnformattedDocument, document.FormattedDocument]
20 layout_classes = [layout.TextLayout, layout.ScrollableTextLayout, layout.IncrementalTextLayout]
21 all_combinations = list(itertools.product(document_classes, layout_classes))
22
23
24 @pytest.mark.parametrize('doctype, layouttype', all_combinations)
25 def test_layout_creation_keyword(doctype, layouttype):
26 _doc = doctype("This is a test")
27 _layout = layouttype(document=_doc, x=X, y=Y, z=Z, width=WIDTH, height=HEIGHT)
28 assert _layout.x == X
29 assert _layout.y == Y
30 assert _layout.z == Z
31 assert _layout.width == WIDTH
32 assert _layout.height == HEIGHT
33 assert _layout.position == (X, Y, Z)
34
35
36 @pytest.mark.parametrize('doctype, layouttype', all_combinations)
37 def test_layout_creation_positional(doctype, layouttype):
38 _doc = doctype("This is a test")
39 _layout = layouttype(_doc, X, Y, Z, WIDTH, HEIGHT)
40 # Make sure the arguments were in order:
41 assert _layout.x == X
42 assert _layout.y == Y
43 assert _layout.z == Z
44 assert _layout.width == WIDTH
45 assert _layout.height == HEIGHT
46 assert _layout.position == (X, Y, Z)