def basic_test_document(text='', settings_overrides={}): reader_name = 'standalone' parser_name = 'restructuredtext' reader_class = readers.get_reader_class(reader_name) reader = reader_class(parser_name=parser_name) parser = reader.parser # we test some things that generate warnings, but don't want those warnings to pollute the test output settings_overrides['warning_stream'] = sys.stdout options = frontend.OptionParser(components=(parser,reader), defaults=settings_overrides) settings = options.get_default_values() document = utils.new_document('rst_test_utils', settings) parser.parse(text, document) #print 'parser.parse(), document=\n%s' % document.asdom().childNodes[0].toprettyxml(' ','\n') return document
def basic_test_document(text='', settings_overrides={}): reader_name = 'standalone' parser_name = 'restructuredtext' reader_class = readers.get_reader_class(reader_name) reader = reader_class(parser_name=parser_name) parser = reader.parser # we test some things that generate warnings, but don't want those warnings to pollute the test output settings_overrides['warning_stream'] = sys.stdout options = frontend.OptionParser(components=(parser, reader), defaults=settings_overrides) settings = options.get_default_values() document = utils.new_document('rst_test_utils', settings) parser.parse(text, document) #print 'parser.parse(), document=\n%s' % document.asdom().childNodes[0].toprettyxml(' ','\n') return document
def set_reader(self, reader_name, parser, parser_name): """Set `self.reader` by name.""" reader_class = readers.get_reader_class(reader_name) self.reader = reader_class(parser, parser_name) self.parser = self.reader.parser
def test_local_reader(self): # requires local-reader.py in test directory (testroot) wr = get_reader_class('local-reader')
def test_registered_reader(self): rdr = get_reader_class('pep')
# Import from itools from itools.gettext import MSG from itools.handlers import checkid from itools.uri import get_reference from itools.web import get_context # Import from ikaaro from ikaaro.text import Text from ikaaro.resource_ import DBResource from page_views import WikiPage_View, WikiPage_Edit, WikiPage_Help from page_views import WikiPage_ToPDF, WikiPage_ToODT, WikiPage_HelpODT from page_views import is_external, BacklinksMenu StandaloneReader = get_reader_class('standalone') def language(argument): try: return argument.encode() except UnicodeEncodeError: raise ValueError('expected "xx-YY" language-COUNTRY code') def yesno(argument): return directives.choice(argument, ('yes', 'no'))