Mercurial > jouvence
comparison tests/test_renderer.py @ 1:74b83e3d921e
Add more states, add more tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 02 Jan 2017 21:54:59 -0800 |
parents | |
children | 6019eee799bf |
comparison
equal
deleted
inserted
replaced
0:243401c49520 | 1:74b83e3d921e |
---|---|
1 import pytest | |
2 from fontaine.renderer import BaseRenderer | |
3 | |
4 | |
5 class TestRenderer(BaseRenderer): | |
6 def write_bold(self, text): | |
7 return 'B:' + text + ':B' | |
8 | |
9 def write_italics(self, text): | |
10 return 'I:' + text + ':I' | |
11 | |
12 def write_underline(self, text): | |
13 return 'U:' + text + ':U' | |
14 | |
15 | |
16 @pytest.mark.parametrize('intext, expected', [ | |
17 ("_Underline_", "U:Underline:U"), | |
18 ("Here's an _underline_.", "Here's an U:underline:U."), | |
19 ("Here's an _underline_ too", "Here's an U:underline:U too"), | |
20 ("This is not_underline_", "This is not_underline_"), | |
21 ("This is not _underline_either", "This is not _underline_either"), | |
22 ("This is _two underlined_ words.", "This is U:two underlined:U words."), | |
23 ("This is _three underlined words_.", | |
24 "This is U:three underlined words:U."), | |
25 ("This is an \_escaped_ one.", "This is an _escaped_ one.") | |
26 ]) | |
27 def test_underline(intext, expected): | |
28 r = TestRenderer() | |
29 out = r.render_text(intext) | |
30 assert out == expected | |
31 | |
32 | |
33 @pytest.mark.parametrize('intext, expected', [ | |
34 ("*Italics*", "I:Italics:I"), | |
35 ("Here's some *italics*.", "Here's some I:italics:I."), | |
36 ("Here's some *italics* too", "Here's some I:italics:I too"), | |
37 ("This is not*italics*", "This is not*italics*"), | |
38 ("This is not *italics*either", "This is not *italics*either"), | |
39 ("This is *two italics* words.", "This is I:two italics:I words."), | |
40 ("This is *three italics words*.", | |
41 "This is I:three italics words:I."), | |
42 ("This is some \*escaped* one.", "This is some *escaped* one.") | |
43 ]) | |
44 def test_italics(intext, expected): | |
45 r = TestRenderer() | |
46 out = r.render_text(intext) | |
47 assert out == expected | |
48 | |
49 | |
50 @pytest.mark.parametrize('intext, expected', [ | |
51 ("**Bold**", "B:Bold:B"), | |
52 ("Here's some **bold**.", "Here's some B:bold:B."), | |
53 ("Here's some **bold** too", "Here's some B:bold:B too"), | |
54 ("This is not**bold**", "This is not**bold**"), | |
55 ("This is not **bold**either", "This is not **bold**either"), | |
56 ("This is **two bold** words.", "This is B:two bold:B words."), | |
57 ("This is **three bold words**.", | |
58 "This is B:three bold words:B."), | |
59 ("This is some \**escaped** one.", "This is some **escaped** one.") | |
60 ]) | |
61 def test_bold(intext, expected): | |
62 r = TestRenderer() | |
63 out = r.render_text(intext) | |
64 assert out == expected |