1 #! /usr/bin/env python3
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
11 from pathlib
import Path
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
):
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
)
41 totest
['paragraphs'] = [
46 <document source="test data">
56 <document source="test data">
68 <document source="test data">
84 <document source="test data">
95 A. Einstein was a really
99 <document source="test data">
101 A. Einstein was a really
106 if __name__
== '__main__':