Mercurial > jouvence
comparison tests/test_renderer.py @ 3:6019eee799bf
Add base classes for rendering.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 03 Jan 2017 09:05:48 -0800 |
parents | 74b83e3d921e |
children | ee741bbe96a8 |
comparison
equal
deleted
inserted
replaced
2:59fe8cb6190d | 3:6019eee799bf |
---|---|
1 import pytest | 1 import pytest |
2 from fontaine.renderer import BaseRenderer | 2 from fontaine.renderer import BaseTextRenderer |
3 | 3 |
4 | 4 |
5 class TestRenderer(BaseRenderer): | 5 class TestTextRenderer(BaseTextRenderer): |
6 def write_bold(self, text): | 6 def make_bold(self, text): |
7 return 'B:' + text + ':B' | 7 return 'B:' + text + ':B' |
8 | 8 |
9 def write_italics(self, text): | 9 def make_italics(self, text): |
10 return 'I:' + text + ':I' | 10 return 'I:' + text + ':I' |
11 | 11 |
12 def write_underline(self, text): | 12 def make_underline(self, text): |
13 return 'U:' + text + ':U' | 13 return 'U:' + text + ':U' |
14 | 14 |
15 | 15 |
16 @pytest.mark.parametrize('intext, expected', [ | 16 @pytest.mark.parametrize('intext, expected', [ |
17 ("_Underline_", "U:Underline:U"), | 17 ("_Underline_", "U:Underline:U"), |
23 ("This is _three underlined words_.", | 23 ("This is _three underlined words_.", |
24 "This is U:three underlined words:U."), | 24 "This is U:three underlined words:U."), |
25 ("This is an \_escaped_ one.", "This is an _escaped_ one.") | 25 ("This is an \_escaped_ one.", "This is an _escaped_ one.") |
26 ]) | 26 ]) |
27 def test_underline(intext, expected): | 27 def test_underline(intext, expected): |
28 r = TestRenderer() | 28 r = TestTextRenderer() |
29 out = r.render_text(intext) | 29 out = r.render_text(intext) |
30 assert out == expected | 30 assert out == expected |
31 | 31 |
32 | 32 |
33 @pytest.mark.parametrize('intext, expected', [ | 33 @pytest.mark.parametrize('intext, expected', [ |
40 ("This is *three italics words*.", | 40 ("This is *three italics words*.", |
41 "This is I:three italics words:I."), | 41 "This is I:three italics words:I."), |
42 ("This is some \*escaped* one.", "This is some *escaped* one.") | 42 ("This is some \*escaped* one.", "This is some *escaped* one.") |
43 ]) | 43 ]) |
44 def test_italics(intext, expected): | 44 def test_italics(intext, expected): |
45 r = TestRenderer() | 45 r = TestTextRenderer() |
46 out = r.render_text(intext) | 46 out = r.render_text(intext) |
47 assert out == expected | 47 assert out == expected |
48 | 48 |
49 | 49 |
50 @pytest.mark.parametrize('intext, expected', [ | 50 @pytest.mark.parametrize('intext, expected', [ |
57 ("This is **three bold words**.", | 57 ("This is **three bold words**.", |
58 "This is B:three bold words:B."), | 58 "This is B:three bold words:B."), |
59 ("This is some \**escaped** one.", "This is some **escaped** one.") | 59 ("This is some \**escaped** one.", "This is some **escaped** one.") |
60 ]) | 60 ]) |
61 def test_bold(intext, expected): | 61 def test_bold(intext, expected): |
62 r = TestRenderer() | 62 r = TestTextRenderer() |
63 out = r.render_text(intext) | 63 out = r.render_text(intext) |
64 assert out == expected | 64 assert out == expected |