Meeting20100904: genshi-py3k-test-patches.diff

File genshi-py3k-test-patches.diff, 5.2 KB (added by Simon Cross, 10 years ago)

Patch to make Trac trunk (r10168) test suite pass against Genshi trunk and Genshi py3k branch.

  • trac/mimeview/api.py

     
    811811                annotators[atype] = annotator
    812812
    813813        if isinstance(stream, list):
    814             stream = HTMLParser(StringIO('\n'.join(stream)))
     814            stream = HTMLParser(StringIO(u'\n'.join(stream)))
    815815        elif isinstance(stream, unicode):
    816816            text = stream
    817817            def linesplitter():
  • trac/mimeview/tests/api.py

     
    126126        self.assertEquals(lines[0].events, [(TEXT, "test", (None, -1, -1))])
    127127
    128128    def test_simplespan(self):
    129         input = HTMLParser(StringIO("<span>test</span>"))
     129        input = HTMLParser(StringIO(u"<span>test</span>"), encoding=None)
    130130        lines = list(_group_lines(input))
    131131        self.assertEquals(len(lines), 1)
    132132        self.assertTrue(isinstance(lines[0], Stream))
     
    168168        If the text element does not end with a newline, it's not properly
    169169        closed.
    170170        """
    171         input = HTMLParser(StringIO('<span class="c">a\nb</span>'))
     171        input = HTMLParser(StringIO(u'<span class="c">a\nb</span>'),
     172            encoding=None)
    172173        expected = ['<span class="c">a</span>',
    173174                    '<span class="c">b</span>',
    174175                   ]
     
    182183        Same as test_newline above, but make sure it behaves properly wrt
    183184        the trailing \\n, especially given it's inside an element.
    184185        """
    185         input = HTMLParser(StringIO('<span class="c">a\nb\n</span>'))
     186        input = HTMLParser(StringIO(u'<span class="c">a\nb\n</span>'),
     187            encoding=None)
    186188        expected = ['<span class="c">a</span>',
    187189                    '<span class="c">b</span>',
    188190                   ]
     
    195197        """
    196198        ditto.
    197199        """
    198         input = HTMLParser(StringIO('<span class="c">\n\n\na</span>'))
     200        input = HTMLParser(StringIO(u'<span class="c">\n\n\na</span>'),
     201            encoding=None)
    199202        expected = ['<span class="c"></span>',
    200203                    '<span class="c"></span>',
    201204                    '<span class="c"></span>',
  • trac/mimeview/tests/patch.py

     
    3535        self.patch = Mimeview(env).renderers[0]
    3636        patch_html = open(os.path.join(os.path.split(__file__)[0],
    3737                                       'patch.html'))
    38         self.patch_html = Stream(list(HTMLParser(patch_html)))
     38        self.patch_html = Stream(list(HTMLParser(patch_html, encoding='utf-8')))
    3939
    4040    def _expected(self, expected_id):
    4141        return self.patch_html.select('//div[@id="%s"]/div' % expected_id)
    4242
    4343    def _test(self, expected_id, result):
    44         expected = str(self._expected(expected_id))
    45         result = str(XML(result))
     44        expected = self._expected(expected_id).render(encoding='utf-8')
     45        result = XML(result.render(encoding='utf-8')).render(encoding='utf-8')
    4646        expected, result = expected.splitlines(), result.splitlines()
    4747        for exp, res in zip(expected, result):
    4848            self.assertEquals(exp, res)
  • trac/mimeview/tests/pygments.py

     
    4242        self.context = Context.from_request(self.req)
    4343        pygments_html = open(os.path.join(os.path.split(__file__)[0],
    4444                                       'pygments.html'))
    45         self.pygments_html = Stream(list(HTMLParser(pygments_html)))
     45        self.pygments_html = Stream(list(HTMLParser(pygments_html, encoding='utf-8')))
    4646
    4747    def _expected(self, expected_id):
    4848        return self.pygments_html.select(
  • trac/web/main.py

     
    696696            req.hdf['projects'] = projects
    697697            req.display(template)
    698698
    699         loader = TemplateLoader(loadpaths, variable_lookup='lenient')
     699        loader = TemplateLoader(loadpaths, variable_lookup='lenient', encoding='utf-8')
    700700        tmpl = loader.load(template)
    701701        stream = tmpl.generate(**data)
    702         output = stream.render('xhtml', doctype=DocType.XHTML_STRICT)
     702        output = stream.render('xhtml', doctype=DocType.XHTML_STRICT, encoding='utf-8')
    703703        req.send(output, 'text/html')
    704704
    705705    except RequestDone:
  • trac/notification.py

     
    399399        # don't translate the e-mail stream
    400400        t = deactivate()
    401401        try:
    402             body = stream.render('text')
     402            body = stream.render('text', encoding='utf-8')
    403403        finally:
    404404            reactivate(t)
    405405        projname = self.env.project_name