Debian Codegraph @

tests/integration/text/test_empty_document.py

raw symbols SCIP
1 import pytest
2
3 from pyglet import gl
4 from pyglet import graphics
5 from pyglet.text import document
6 from pyglet.text import layout
7 from pyglet import window
8
9
10 @pytest.fixture(params=[document.UnformattedDocument, document.FormattedDocument])
11 def text_window(request):
12
13 class _TestWindow(window.Window):
14 def __init__(self, doctype, *args, **kwargs):
15 super().__init__(*args, **kwargs)
16
17 self.batch = graphics.Batch()
18 self.document = doctype()
19 self.layout = layout.IncrementalTextLayout(
20 self.document, 0, 0, 0, self.width, self.height, batch=self.batch)
21
22 def on_draw(self):
23 gl.glClearColor(1, 1, 1, 1)
24 self.clear()
25 self.batch.draw()
26
27 def set_weight(self, weight):
28 self.document.set_style(0, len(self.document.text), {"weight": weight})
29
30 return _TestWindow(request.param)
31
32
33 def test_empty_document(text_window):
34 """Empty text document can be rendered."""
35 text_window.dispatch_events()
36 text_window.close()
37
38
39 def test_empty_document_bold(text_window):
40 """Empty text document can be rendered and attributes can be set."""
41 text_window.set_weight("bold")
42 text_window.dispatch_events()
43 text_window.close()