# -*- 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 doctest import os import unittest import shutil import sys import tempfile from genshi import i18n from genshi.i18n import extract_from_template #from genshi.core import Markup, Stream from genshi.template import MarkupTemplate, Template, TextTemplate class LangExtractionTestCase(unittest.TestCase): """TODO""" def test_extract_from_text(self): tmpl = MarkupTemplate(""" Some text """) self.assertEqual([('body', 'Some text')], list(extract_from_template(tmpl))) def test_extract_from_expression(self): tmpl = MarkupTemplate(""" ${_('single quoted')} ${_("double quoted")} """) self.assertEqual([('body', 'single quoted'), ('body', 'double quoted')], list(extract_from_template(tmpl))) def test_extract_from_attibute_expression(self): tmpl = MarkupTemplate("""

""") self.assertEqual([('p', 'A Title')], list(extract_from_template(tmpl))) def test_extract_from_attibute_text(self): tmpl = MarkupTemplate(""" alt text """) 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 suite if __name__ == '__main__': unittest.main(defaultTest='suite')