Mercurial > babel > old > mirror
comparison babel/messages/tests/catalog.py @ 107:4b42e23644e5
`Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
The `Generated-By` header value needed a missing `\n`.
The frontends now pass the value of `--copyright-holder` to the Catalog, and removed the `copyright_holder` arg for `write_po` left behind on [105].
Tests changed accordingly.
author | palgarvio |
---|---|
date | Thu, 14 Jun 2007 06:24:28 +0000 |
parents | debd9ac3bb4d |
children | 0c18f72fcb76 |
comparison
equal
deleted
inserted
replaced
106:2a00e352c986 | 107:4b42e23644e5 |
---|---|
22 | 22 |
23 def test_python_format(self): | 23 def test_python_format(self): |
24 assert catalog.PYTHON_FORMAT('foo %d bar') | 24 assert catalog.PYTHON_FORMAT('foo %d bar') |
25 assert catalog.PYTHON_FORMAT('foo %s bar') | 25 assert catalog.PYTHON_FORMAT('foo %s bar') |
26 assert catalog.PYTHON_FORMAT('foo %r bar') | 26 assert catalog.PYTHON_FORMAT('foo %r bar') |
27 | 27 |
28 def test_translator_comments(self): | 28 def test_translator_comments(self): |
29 mess = catalog.Message('foo', comments=['Comment About `foo`']) | 29 mess = catalog.Message('foo', user_comments=['Comment About `foo`']) |
30 self.assertEqual(mess.comments, ['Comment About `foo`']) | 30 self.assertEqual(mess.user_comments, ['Comment About `foo`']) |
31 mess = catalog.Message('foo', | 31 mess = catalog.Message('foo', |
32 comments=['Comment 1 About `foo`', | 32 auto_comments=['Comment 1 About `foo`', |
33 'Comment 2 About `foo`']) | 33 'Comment 2 About `foo`']) |
34 self.assertEqual(mess.comments, ['Comment 1 About `foo`', | 34 self.assertEqual(mess.auto_comments, ['Comment 1 About `foo`', |
35 'Comment 2 About `foo`']) | 35 'Comment 2 About `foo`']) |
36 | 36 |
37 | 37 |
38 class CatalogTestCase(unittest.TestCase): | 38 class CatalogTestCase(unittest.TestCase): |
39 | 39 |
44 self.assertEqual(1, len(cat)) | 44 self.assertEqual(1, len(cat)) |
45 | 45 |
46 def test_update_message_updates_comments(self): | 46 def test_update_message_updates_comments(self): |
47 cat = catalog.Catalog() | 47 cat = catalog.Catalog() |
48 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 5)]) | 48 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 5)]) |
49 self.assertEqual(cat[u'foo'].comments, []) | 49 self.assertEqual(cat[u'foo'].auto_comments, []) |
50 self.assertEqual(cat[u'foo'].user_comments, []) | |
50 # Update cat[u'foo'] with a new location and a comment | 51 # Update cat[u'foo'] with a new location and a comment |
51 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 7)], | 52 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 7)], |
52 comments=['Foo Bar comment 1']) | 53 user_comments=['Foo Bar comment 1']) |
53 self.assertEqual(cat[u'foo'].comments, ['Foo Bar comment 1']) | 54 self.assertEqual(cat[u'foo'].user_comments, ['Foo Bar comment 1']) |
54 # now add yet another location with another comment | 55 # now add yet another location with another comment |
55 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 9)], | 56 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 9)], |
56 comments=['Foo Bar comment 2']) | 57 auto_comments=['Foo Bar comment 2']) |
57 self.assertEqual(cat[u'foo'].comments, | 58 self.assertEqual(cat[u'foo'].auto_comments, ['Foo Bar comment 2']) |
58 ['Foo Bar comment 1', 'Foo Bar comment 2']) | |
59 | 59 |
60 | 60 |
61 def suite(): | 61 def suite(): |
62 suite = unittest.TestSuite() | 62 suite = unittest.TestSuite() |
63 suite.addTest(doctest.DocTestSuite(catalog, optionflags=doctest.ELLIPSIS)) | 63 suite.addTest(doctest.DocTestSuite(catalog, optionflags=doctest.ELLIPSIS)) |