26c7eadf30a2239bd7da9a6a4ed33fbc0357d687
[rst2info.git] / texinfo / rst_test_utils.py
1 import unittest
2 from docutils import utils, frontend, core, readers
3 from docutils.parsers import rst
4 from info_translator import InfoTranslator
5
6 def basic_test_document(text=''):
7 reader_name = 'standalone'
8 parser_name = 'restructuredtext'
9
10 reader_class = readers.get_reader_class(reader_name)
11 reader = reader_class(None, parser_name)
12 parser = reader.parser
13
14 options = frontend.OptionParser(components=(parser,reader))
15 settings = options.get_default_values()
16 document = utils.new_document('rst_test_utils', settings)
17
18 parser.parse(text, document)
19
20 #print 'document:\n%s' % document.asdom().childNodes[0].toprettyxml(' ','\n')
21 return document
22
23 class TestCase(unittest.TestCase):
24 def given_input(self, input):
25 self.document = basic_test_document(input)
26