Debian Codegraph @

tests/platforms/windows/app/create/test_txt_to_rtf.py

raw
1 from textwrap import dedent
2
3 import pytest
4
5 from briefcase.platforms.windows import txt_to_rtf
6
7
8 @pytest.mark.parametrize(
9 ("input", "expected"),
10 [
11 pytest.param(
12 "",
13 "{\\rtf1\\ansi\\deff0 {\\fonttbl {\\f0 Courier;}}\n\\par\\line\n}",
14 id="empty-doc",
15 ),
16 pytest.param(
17 """\
18 Hello World.
19
20 This is a 2 paragraph document
21 with a multi-line paragraph.
22 """,
23 """\
24 {\\rtf1\\ansi\\deff0 {\\fonttbl {\\f0 Courier;}}
25 Hello World.\x20
26 \\par\\line
27 This is a 2 paragraph document\x20
28 with a multi-line paragraph.\x20
29 \\par\\line
30 }""",
31 id="2-para-document",
32 ),
33 pytest.param(
34 """\
35 This is a document that contains bullet points:
36
37 * first, something short
38 * then, something longer that needs to
39 run onto multiple lines
40 * last, something short again
41
42 Then a closing paragraph.
43 """,
44 """\
45 {\\rtf1\\ansi\\deff0 {\\fonttbl {\\f0 Courier;}}
46 This is a document that contains bullet points:\x20
47 \\par\\line
48 \\bullet first, something short\x20
49 \\bullet then, something longer that needs to\x20
50 run onto multiple lines\x20
51 \\bullet last, something short again\x20
52 \\par\\line
53 Then a closing paragraph.\x20
54 \\par\\line
55 }""",
56 id="bullet-document",
57 ),
58 ],
59 )
60 def test_txt_to_rtf(input, expected):
61 """Utility method can convert TXT to RTF format."""
62 assert txt_to_rtf(dedent(input)) == dedent(expected)