Mercurial > genshi > mirror
changeset 667:c9a084ffaee6 trunk
Fix case where attributes weren't properly wrapped in an `Attrs` instance if one or more of them were translated by the I18n filter, potentially breaking things further down the chain. Closes #162.
author | cmlenz |
---|---|
date | Tue, 11 Dec 2007 21:17:18 +0000 |
parents | 050657e221d4 |
children | f102141fe331 |
files | genshi/filters/i18n.py genshi/filters/tests/i18n.py |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi/filters/i18n.py +++ b/genshi/filters/i18n.py @@ -174,7 +174,7 @@ changed = True new_attrs.append((name, value)) if changed: - attrs = new_attrs + attrs = Attrs(new_attrs) if msgbuf: msgbuf.append(kind, data, pos)
--- a/genshi/filters/tests/i18n.py +++ b/genshi/filters/tests/i18n.py @@ -15,12 +15,26 @@ from StringIO import StringIO import unittest +from genshi.core import Attrs from genshi.template import MarkupTemplate from genshi.filters.i18n import Translator, extract +from genshi.input import HTML class TranslatorTestCase(unittest.TestCase): + def test_translate_included_attribute_text(self): + """ + Verify that translated attributes end up in a proper `Attrs` instance. + """ + html = HTML("""<html> + <span title="Foo"></span> + </html>""") + translator = Translator(lambda s: u"Voh") + stream = list(html.filter(translator)) + kind, data, pos = stream[2] + assert isinstance(data[1], Attrs) + def test_extract_without_text(self): tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"> <p title="Bar">Foo</p>