HISTORY summary
[docutils.git] / test / test_parsers / test_parser.py
blob29be2ab98ee96249ee89e523cfda66121345f1c5
1 #! /usr/bin/env python
3 # $Id$
4 # Author: Stefan Rank <strank(AT)strank(DOT)info>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for basic functionality of parser classes.
9 """
11 import sys
12 import unittest
13 import DocutilsTestSupport # must be imported before docutils
14 import 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)
31 else:
32 # input must be unicode at all times
33 self.assertRaises(TypeError, parser.parse, b('hol'), document)
36 if __name__ == '__main__':
37 unittest.main()