view MoinMoin/parser/_tests/ @ 5829:a744f573fe30

advancedsearch: fix problem with non-ascii chars breaking up words for OR and NOT terms
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 04 Feb 2012 16:52:24 +0100
parents 2b7f9e89e442
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - MoinMoin.parser.text_csv Tests

    @copyright: 2008 by MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.

import re
from StringIO import StringIO

import py

from MoinMoin.Page import Page
from MoinMoin.parser.text_csv import Parser as CSV_Parser
from MoinMoin.formatter.text_html import Formatter as HtmlFormatter

PAGENAME = u'ThisPageDoesNotExistsAndWillNeverBeReally'

class ParserTestCase(object):
    """ Helper class that provide a parsing method """

    def parse(self, body):
        """Parse body and return html

        Create a page with body, then parse it and format using html formatter
        request = self.request
        assert body is not None
        page = Page(request, PAGENAME)
        page.hilite_re = None
        formatter = HtmlFormatter(request)
        page.formatter = formatter = page
        request.formatter = formatter
        parser = CSV_Parser(body, request, line_anchors=False)
        formatter.startContent('') # needed for _include_stack init
        output = request.redirectedOutput(parser.format, formatter)
        return output

class TestDelimiters(ParserTestCase):

    def testdelimiters(self):
        """ parser.text_csv: delimiter , """
        result = self.parse('a,b')
        assert '<td class="hcolumn0"><strong>a</strong></td>' in  result and '<td class="hcolumn1"><strong>b</strong></td>' in  result

    def testemptyline(self):
        """ parser.text_csv: empty line """
        result = self.parse('')
        assert '<tbody><tr></tr>\n</tbody>' in  result

    def testnodelimiter(self):
        """ parser.text_csv: line without delimiter """
        result = self.parse('ABCDEFGHIJ')
        assert '<td class="hcolumn0"><strong>ABCDEFGHIJ</strong></td>' in  result

coverage_modules = ['MoinMoin.parser.text_csv']