Debian Codegraph @

test/test_writers/test_null.py

raw symbols SCIP
1 #!/usr/bin/env python3
2
3 # $Id: test_null.py 9914 2024-08-21 13:45:08Z milde $
4 # Author: Lea Wiemann <[email protected]>
5 # Copyright: This module has been placed in the public domain.
6
7 """
8 Test for Null writer.
9 """
10
11 from pathlib import Path
12 import sys
13 import unittest
14
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[2]))
19
20 from docutils.core import publish_string
21 from docutils.writers import null
22
23
24 class WriterPublishTestCase(unittest.TestCase):
25 def test_publish(self):
26 for name, cases in totest.items():
27 for casenum, (case_input, case_expected) in enumerate(cases):
28 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
29 output = publish_string(
30 source=case_input,
31 writer=null.Writer(),
32 settings_overrides={
33 '_disable_config': True,
34 'strict_visitor': True,
35 },
36 )
37 if isinstance(output, bytes):
38 output = output.decode('utf-8')
39 self.assertEqual(case_expected, output)
40
41
42 totest = {}
43
44 totest['basic'] = [
45 ["""\
46 This is a paragraph.
47 """,
48 '']
49 ]
50
51 if __name__ == '__main__':
52 unittest.main()