Debian Codegraph @

test/test_writers/test_get_writer_class.py

raw symbols SCIP
1 #! /usr/bin/env python3
2
3 # $Id: test_get_writer_class.py 9748 2024-06-08 08:08:37Z milde $
4 # Author: grubert
5 # Maintainer: [email protected]
6 # Copyright: This module has been placed in the public domain.
7
8 """
9 test get_writer_class
10 """
11
12 from pathlib import Path
13 import sys
14 import unittest
15
16 # Prepend the "docutils root" to the Python library path
17 # so we import the local `docutils` and `test` packages.
18 # Ensure `test` package can be loaded also if not running as __main__
19 # (required by ``python -m unittest``
20 DOCUTILS_ROOT = Path(__file__).resolve().parents[2]
21 if str(DOCUTILS_ROOT) not in sys.path:
22 sys.path.insert(0, str(DOCUTILS_ROOT))
23
24 from docutils.writers import get_writer_class # noqa: E402
25
26
27 class GetWriterClassTestCase(unittest.TestCase):
28
29 def test_registered_writer(self):
30 get_writer_class('manpage')
31 # raises ImportError on failure
32
33 def test_bogus_writer(self):
34 with self.assertRaises(ImportError):
35 get_writer_class('nope')
36
37 def test_local_writer(self):
38 # imports local-writer.py from the test package (added above)
39 get_writer_class('test.local-writer')
40 # raises ImportError on failure
41
42
43 if __name__ == '__main__':
44 unittest.main()