cmlenz@58: # -*- coding: utf-8 -*- cmlenz@58: # cmlenz@58: # Copyright (C) 2007 Edgewall Software cmlenz@58: # All rights reserved. cmlenz@58: # cmlenz@58: # This software is licensed as described in the file COPYING, which cmlenz@58: # you should have received as part of this distribution. The terms cmlenz@58: # are also available at http://babel.edgewall.org/wiki/License. cmlenz@58: # cmlenz@58: # This software consists of voluntary contributions made by many cmlenz@58: # individuals. For the exact contribution history, see the revision cmlenz@58: # history and logs, available at http://babel.edgewall.org/log/. cmlenz@58: cmlenz@58: import doctest cmlenz@58: from StringIO import StringIO cmlenz@58: import unittest cmlenz@58: cmlenz@58: from babel.messages import catalog cmlenz@58: cmlenz@58: cmlenz@58: class MessageTestCase(unittest.TestCase): cmlenz@58: cmlenz@58: def test_python_format(self): cmlenz@58: assert catalog.PYTHON_FORMAT('foo %d bar') cmlenz@58: assert catalog.PYTHON_FORMAT('foo %s bar') palgarvio@82: assert catalog.PYTHON_FORMAT('foo %r bar') palgarvio@82: palgarvio@82: def test_translator_comments(self): palgarvio@82: mess = catalog.Message('foo', comments=['Comment About `foo`']) palgarvio@82: self.assertEqual(mess.comments, ['Comment About `foo`']) palgarvio@82: mess = catalog.Message('foo', palgarvio@82: comments=['Comment 1 About `foo`', palgarvio@82: 'Comment 2 About `foo`']) palgarvio@82: self.assertEqual(mess.comments, ['Comment 1 About `foo`', palgarvio@82: 'Comment 2 About `foo`']) cmlenz@58: cmlenz@58: cmlenz@71: class CatalogTestCase(unittest.TestCase): cmlenz@71: cmlenz@71: def test_two_messages_with_same_singular(self): cmlenz@71: cat = catalog.Catalog() cmlenz@71: cat.add('foo') cmlenz@71: cat.add(('foo', 'foos')) cmlenz@71: self.assertEqual(1, len(cat)) cmlenz@71: cmlenz@71: cmlenz@58: def suite(): cmlenz@58: suite = unittest.TestSuite() cmlenz@69: suite.addTest(doctest.DocTestSuite(catalog, optionflags=doctest.ELLIPSIS)) cmlenz@58: suite.addTest(unittest.makeSuite(MessageTestCase)) cmlenz@71: suite.addTest(unittest.makeSuite(CatalogTestCase)) cmlenz@58: return suite cmlenz@58: cmlenz@58: if __name__ == '__main__': cmlenz@58: unittest.main(defaultTest='suite')