4 # Author: Stefan Rank <strank(AT)strank(DOT)info>
5 # Copyright: This module has been placed in the public domain.
8 Tests for basic functionality of parser classes.
13 import DocutilsTestSupport
# must be imported before docutils
15 from docutils
import parsers
, utils
, frontend
16 from docutils
._compat
import b
19 class RstParserTests(unittest
.TestCase
):
21 def test_inputrestrictions(self
):
22 parser_class
= parsers
.get_parser_class('rst')
23 parser
= parser_class()
24 document
= utils
.new_document('test data', frontend
.OptionParser(
25 components
=(parser
, )).get_default_values())
27 if sys
.version_info
< (3,):
28 # supplying string input is supported, but only if ascii-decodable
29 self
.assertRaises(UnicodeDecodeError,
30 parser
.parse
, b('hol%s' % chr(224)), document
)
32 # input must be unicode at all times
33 self
.assertRaises(TypeError, parser
.parse
, b('hol'), document
)
36 if __name__
== '__main__':