Meeting20100904: genshi-py3k-test-patches.diff
File genshi-py3k-test-patches.diff, 5.2 KB (added by , 14 years ago) |
---|
-
trac/mimeview/api.py
811 811 annotators[atype] = annotator 812 812 813 813 if isinstance(stream, list): 814 stream = HTMLParser(StringIO( '\n'.join(stream)))814 stream = HTMLParser(StringIO(u'\n'.join(stream))) 815 815 elif isinstance(stream, unicode): 816 816 text = stream 817 817 def linesplitter(): -
trac/mimeview/tests/api.py
126 126 self.assertEquals(lines[0].events, [(TEXT, "test", (None, -1, -1))]) 127 127 128 128 def test_simplespan(self): 129 input = HTMLParser(StringIO( "<span>test</span>"))129 input = HTMLParser(StringIO(u"<span>test</span>"), encoding=None) 130 130 lines = list(_group_lines(input)) 131 131 self.assertEquals(len(lines), 1) 132 132 self.assertTrue(isinstance(lines[0], Stream)) … … 168 168 If the text element does not end with a newline, it's not properly 169 169 closed. 170 170 """ 171 input = HTMLParser(StringIO('<span class="c">a\nb</span>')) 171 input = HTMLParser(StringIO(u'<span class="c">a\nb</span>'), 172 encoding=None) 172 173 expected = ['<span class="c">a</span>', 173 174 '<span class="c">b</span>', 174 175 ] … … 182 183 Same as test_newline above, but make sure it behaves properly wrt 183 184 the trailing \\n, especially given it's inside an element. 184 185 """ 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) 186 188 expected = ['<span class="c">a</span>', 187 189 '<span class="c">b</span>', 188 190 ] … … 195 197 """ 196 198 ditto. 197 199 """ 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) 199 202 expected = ['<span class="c"></span>', 200 203 '<span class="c"></span>', 201 204 '<span class="c"></span>', -
trac/mimeview/tests/patch.py
35 35 self.patch = Mimeview(env).renderers[0] 36 36 patch_html = open(os.path.join(os.path.split(__file__)[0], 37 37 'patch.html')) 38 self.patch_html = Stream(list(HTMLParser(patch_html )))38 self.patch_html = Stream(list(HTMLParser(patch_html, encoding='utf-8'))) 39 39 40 40 def _expected(self, expected_id): 41 41 return self.patch_html.select('//div[@id="%s"]/div' % expected_id) 42 42 43 43 def _test(self, expected_id, result): 44 expected = s tr(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') 46 46 expected, result = expected.splitlines(), result.splitlines() 47 47 for exp, res in zip(expected, result): 48 48 self.assertEquals(exp, res) -
trac/mimeview/tests/pygments.py
42 42 self.context = Context.from_request(self.req) 43 43 pygments_html = open(os.path.join(os.path.split(__file__)[0], 44 44 'pygments.html')) 45 self.pygments_html = Stream(list(HTMLParser(pygments_html )))45 self.pygments_html = Stream(list(HTMLParser(pygments_html, encoding='utf-8'))) 46 46 47 47 def _expected(self, expected_id): 48 48 return self.pygments_html.select( -
trac/web/main.py
696 696 req.hdf['projects'] = projects 697 697 req.display(template) 698 698 699 loader = TemplateLoader(loadpaths, variable_lookup='lenient' )699 loader = TemplateLoader(loadpaths, variable_lookup='lenient', encoding='utf-8') 700 700 tmpl = loader.load(template) 701 701 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') 703 703 req.send(output, 'text/html') 704 704 705 705 except RequestDone: -
trac/notification.py
399 399 # don't translate the e-mail stream 400 400 t = deactivate() 401 401 try: 402 body = stream.render('text' )402 body = stream.render('text', encoding='utf-8') 403 403 finally: 404 404 reactivate(t) 405 405 projname = self.env.project_name