Clean up and update TODO list.
[docutils.git] / docutils / test / test_parsers / test_rst / test_paragraphs.py
blobeeac81ef368449dd37a81cef54fec5f43ae24f85
1 #! /usr/bin/env python3
3 # $Id$
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for states.py.
9 """
11 from pathlib import Path
12 import sys
13 import unittest
15 if __name__ == '__main__':
16 # prepend the "docutils root" to the Python library path
17 # so we import the local `docutils` package.
18 sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
20 from docutils.frontend import get_default_settings
21 from docutils.parsers.rst import Parser
22 from docutils.utils import new_document
25 class ParserTestCase(unittest.TestCase):
26 def test_parser(self):
27 parser = Parser()
28 settings = get_default_settings(Parser)
29 settings.warning_stream = ''
30 for name, cases in totest.items():
31 for casenum, (case_input, case_expected) in enumerate(cases):
32 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
33 document = new_document('test data', settings.copy())
34 parser.parse(case_input, document)
35 output = document.pformat()
36 self.assertEqual(case_expected, output)
39 totest = {}
41 totest['paragraphs'] = [
42 ["""\
43 A paragraph.
44 """,
45 """\
46 <document source="test data">
47 <paragraph>
48 A paragraph.
49 """],
50 ["""\
51 Paragraph 1.
53 Paragraph 2.
54 """,
55 """\
56 <document source="test data">
57 <paragraph>
58 Paragraph 1.
59 <paragraph>
60 Paragraph 2.
61 """],
62 ["""\
63 Line 1.
64 Line 2.
65 Line 3.
66 """,
67 """\
68 <document source="test data">
69 <paragraph>
70 Line 1.
71 Line 2.
72 Line 3.
73 """],
74 ["""\
75 Paragraph 1, Line 1.
76 Line 2.
77 Line 3.
79 Paragraph 2, Line 1.
80 Line 2.
81 Line 3.
82 """,
83 """\
84 <document source="test data">
85 <paragraph>
86 Paragraph 1, Line 1.
87 Line 2.
88 Line 3.
89 <paragraph>
90 Paragraph 2, Line 1.
91 Line 2.
92 Line 3.
93 """],
94 ["""\
95 A. Einstein was a really
96 smart dude.
97 """,
98 """\
99 <document source="test data">
100 <paragraph>
101 A. Einstein was a really
102 smart dude.
103 """],
106 if __name__ == '__main__':
107 unittest.main()