File: test_misc.py

package info (click to toggle)
python-docutils 0.22%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 11,448 kB
  • sloc: python: 53,302; lisp: 14,475; xml: 1,807; javascript: 1,032; makefile: 102; sh: 96
file content (34 lines) | stat: -rwxr-xr-x 1,003 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /usr/bin/env python3
# $Id: test_misc.py 9644 2024-04-15 18:34:05Z milde $
# Author: Stefan Rank <strank(AT)strank(DOT)info>
# Copyright: This module has been placed in the public domain.

"""
Tests for basic functionality of parser classes.
"""

from pathlib import Path
import sys
import unittest

if __name__ == '__main__':
    # prepend the local "docutils root" to the Python library path
    sys.path.insert(0, Path(__file__).resolve().parents[2].as_posix())

from docutils import frontend, utils
import docutils.parsers.rst


class RstParserTests(unittest.TestCase):

    def test_inputrestrictions(self):
        # input must be unicode at all times, check for meaningful Exception
        parser = docutils.parsers.rst.Parser()
        document = utils.new_document('test data',
                                      frontend.get_default_settings(parser))
        with self.assertRaises(TypeError):
            parser.parse(b'hol', document)


if __name__ == '__main__':
    unittest.main()