# -*- coding: utf-8 -*-## Copyright (C) 2006 Edgewall Software# All rights reserved.## This software is licensed as described in the file COPYING, which# you should have received as part of this distribution. The terms# are also available at http://genshi.edgewall.org/wiki/License.## This software consists of voluntary contributions made by many# individuals. For the exact contribution history, see the revision# history and logs, available at http://genshi.edgewall.org/log/.import doctestimport osimport unittestimport shutilimport sysimport tempfilefrom genshi import i18nfrom genshi.i18n import extract_from_template#from genshi.core import Markup, Streamfrom genshi.template import MarkupTemplate, Template, TextTemplateclass LangExtractionTestCase(unittest.TestCase): """TODO""" def test_extract_from_text(self): tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"> <body>Some text</body> </html>""") self.assertEqual([('body', 'Some text')], list(extract_from_template(tmpl))) def test_extract_from_expression(self): tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"> <body> ${_('single quoted')} ${_("double quoted")} </body> </html>""") self.assertEqual([('body', 'single quoted'), ('body', 'double quoted')], list(extract_from_template(tmpl))) def test_extract_from_attibute_expression(self): tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"> <body><p title="${_('A Title')}"></p></body> </html>""") self.assertEqual([('p', 'A Title')], list(extract_from_template(tmpl))) def test_extract_from_attibute_text(self): tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"> <body><img title="img title" alt="alt text" /></body> </html>""") self.assertEqual([('img', 'img title'), ('img', 'alt text')], list(extract_from_template(tmpl)))def suite(): suite = unittest.TestSuite() #suite.addTest(doctest.DocTestSuite(i18n)) suite.addTest(unittest.makeSuite(LangExtractionTestCase, 'test')) return suiteif __name__ == '__main__': unittest.main(defaultTest='suite')