annotate babel/messages/tests/catalog.py @ 544:030ddf3f5b13

catalog.add() now returns the message instance (closes #245)
author fschwarz
date Sat, 19 Mar 2011 19:28:59 +0000
parents 85e1beadacb0
children
rev   line source
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
2 #
530
85e1beadacb0 Update the copyright line.
jruigrok
parents: 466
diff changeset
3 # Copyright (C) 2007-2011 Edgewall Software
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
4 # All rights reserved.
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
5 #
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
8 # are also available at http://babel.edgewall.org/wiki/License.
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
9 #
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
12 # history and logs, available at http://babel.edgewall.org/log/.
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
13
419
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
14 import copy
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
15 import datetime
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
16 import doctest
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
17 import unittest
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
18
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
19 from babel.messages import catalog
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
20
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
21
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
22 class MessageTestCase(unittest.TestCase):
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
23
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
24 def test_python_format(self):
220
677147547e2d Added infrastructure for adding catalog checkers, and implement a checker that validations Python format parameters in translations, closing #19.
cmlenz
parents: 200
diff changeset
25 assert catalog.PYTHON_FORMAT.search('foo %d bar')
677147547e2d Added infrastructure for adding catalog checkers, and implement a checker that validations Python format parameters in translations, closing #19.
cmlenz
parents: 200
diff changeset
26 assert catalog.PYTHON_FORMAT.search('foo %s bar')
677147547e2d Added infrastructure for adding catalog checkers, and implement a checker that validations Python format parameters in translations, closing #19.
cmlenz
parents: 200
diff changeset
27 assert catalog.PYTHON_FORMAT.search('foo %r bar')
225
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
28 assert catalog.PYTHON_FORMAT.search('foo %(name).1f')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
29 assert catalog.PYTHON_FORMAT.search('foo %(name)3.3f')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
30 assert catalog.PYTHON_FORMAT.search('foo %(name)3f')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
31 assert catalog.PYTHON_FORMAT.search('foo %(name)06d')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
32 assert catalog.PYTHON_FORMAT.search('foo %(name)Li')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
33 assert catalog.PYTHON_FORMAT.search('foo %(name)#d')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
34 assert catalog.PYTHON_FORMAT.search('foo %(name)-4.4hs')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
35 assert catalog.PYTHON_FORMAT.search('foo %(name)*.3f')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
36 assert catalog.PYTHON_FORMAT.search('foo %(name).*f')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
37 assert catalog.PYTHON_FORMAT.search('foo %(name)3.*f')
3703ded648ab Applied patch by Ramiro Morales for more extensive detection of Python string formatting specifiers. Closes #57.
cmlenz
parents: 220
diff changeset
38 assert catalog.PYTHON_FORMAT.search('foo %(name)*.*f')
358
6ea52d9bdab1 Message.clone doesn't return a shallow copy any longer. This fixes a bug with update where flags where shared.
aronacher
parents: 350
diff changeset
39 assert catalog.PYTHON_FORMAT.search('foo %()s')
105
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
40
80
9c84b9fa5d30 Added support for translator comments at the API and frontends levels.(See #12, item 1). Updated docs and tests accordingly.
palgarvio
parents: 69
diff changeset
41 def test_translator_comments(self):
105
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
42 mess = catalog.Message('foo', user_comments=['Comment About `foo`'])
200
2983c718f6e2 Added `--no-fuzzy-matching` to the frontends and also `--previous` which adds the old msgid's as comments. The latest closes #31.
palgarvio
parents: 181
diff changeset
43 self.assertEqual(mess.user_comments, ['Comment About `foo`'])
80
9c84b9fa5d30 Added support for translator comments at the API and frontends levels.(See #12, item 1). Updated docs and tests accordingly.
palgarvio
parents: 69
diff changeset
44 mess = catalog.Message('foo',
105
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
45 auto_comments=['Comment 1 About `foo`',
80
9c84b9fa5d30 Added support for translator comments at the API and frontends levels.(See #12, item 1). Updated docs and tests accordingly.
palgarvio
parents: 69
diff changeset
46 'Comment 2 About `foo`'])
105
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
47 self.assertEqual(mess.auto_comments, ['Comment 1 About `foo`',
80
9c84b9fa5d30 Added support for translator comments at the API and frontends levels.(See #12, item 1). Updated docs and tests accordingly.
palgarvio
parents: 69
diff changeset
48 'Comment 2 About `foo`'])
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
49
358
6ea52d9bdab1 Message.clone doesn't return a shallow copy any longer. This fixes a bug with update where flags where shared.
aronacher
parents: 350
diff changeset
50 def test_clone_message_object(self):
6ea52d9bdab1 Message.clone doesn't return a shallow copy any longer. This fixes a bug with update where flags where shared.
aronacher
parents: 350
diff changeset
51 msg = catalog.Message('foo', locations=[('foo.py', 42)])
6ea52d9bdab1 Message.clone doesn't return a shallow copy any longer. This fixes a bug with update where flags where shared.
aronacher
parents: 350
diff changeset
52 clone = msg.clone()
6ea52d9bdab1 Message.clone doesn't return a shallow copy any longer. This fixes a bug with update where flags where shared.
aronacher
parents: 350
diff changeset
53 clone.locations.append(('bar.py', 42))
6ea52d9bdab1 Message.clone doesn't return a shallow copy any longer. This fixes a bug with update where flags where shared.
aronacher
parents: 350
diff changeset
54 self.assertEqual(msg.locations, [('foo.py', 42)])
359
ad98cc9a7eec Updated catalog test case for last commit, flags are now tested too in the clone test case.
aronacher
parents: 358
diff changeset
55 msg.flags.add('fuzzy')
ad98cc9a7eec Updated catalog test case for last commit, flags are now tested too in the clone test case.
aronacher
parents: 358
diff changeset
56 assert not clone.fuzzy and msg.fuzzy
358
6ea52d9bdab1 Message.clone doesn't return a shallow copy any longer. This fixes a bug with update where flags where shared.
aronacher
parents: 350
diff changeset
57
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
58
69
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
59 class CatalogTestCase(unittest.TestCase):
544
030ddf3f5b13 catalog.add() now returns the message instance (closes #245)
fschwarz
parents: 530
diff changeset
60 def test_add_returns_message_instance(self):
030ddf3f5b13 catalog.add() now returns the message instance (closes #245)
fschwarz
parents: 530
diff changeset
61 cat = catalog.Catalog()
030ddf3f5b13 catalog.add() now returns the message instance (closes #245)
fschwarz
parents: 530
diff changeset
62 message = cat.add('foo')
030ddf3f5b13 catalog.add() now returns the message instance (closes #245)
fschwarz
parents: 530
diff changeset
63 self.assertEquals('foo', message.id)
69
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
64
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
65 def test_two_messages_with_same_singular(self):
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
66 cat = catalog.Catalog()
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
67 cat.add('foo')
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
68 cat.add(('foo', 'foos'))
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
69 self.assertEqual(1, len(cat))
95
008cd3f7d485 Fix for #11 (use local timezone in timestamps of generated POT).
cmlenz
parents: 89
diff changeset
70
227
01dd895f396c Fix tests broken by [233], and add new tests.
cmlenz
parents: 225
diff changeset
71 def test_duplicate_auto_comment(self):
228
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
72 cat = catalog.Catalog()
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
73 cat.add('foo', auto_comments=['A comment'])
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
74 cat.add('foo', auto_comments=['A comment', 'Another comment'])
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
75 self.assertEqual(['A comment', 'Another comment'],
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
76 cat['foo'].auto_comments)
227
01dd895f396c Fix tests broken by [233], and add new tests.
cmlenz
parents: 225
diff changeset
77
01dd895f396c Fix tests broken by [233], and add new tests.
cmlenz
parents: 225
diff changeset
78 def test_duplicate_user_comment(self):
228
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
79 cat = catalog.Catalog()
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
80 cat.add('foo', user_comments=['A comment'])
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
81 cat.add('foo', user_comments=['A comment', 'Another comment'])
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
82 self.assertEqual(['A comment', 'Another comment'],
fd29fabdc986 Follow-up to [239]: also combine duplicate comments when writing PO files.
cmlenz
parents: 227
diff changeset
83 cat['foo'].user_comments)
227
01dd895f396c Fix tests broken by [233], and add new tests.
cmlenz
parents: 225
diff changeset
84
230
2097287603e7 Forgot to update test method name after copy/paste.
cmlenz
parents: 229
diff changeset
85 def test_duplicate_location(self):
229
9a3f2acb55e6 Remove duplicate locations of catalog messages.
cmlenz
parents: 228
diff changeset
86 cat = catalog.Catalog()
9a3f2acb55e6 Remove duplicate locations of catalog messages.
cmlenz
parents: 228
diff changeset
87 cat.add('foo', locations=[('foo.py', 1)])
9a3f2acb55e6 Remove duplicate locations of catalog messages.
cmlenz
parents: 228
diff changeset
88 cat.add('foo', locations=[('foo.py', 1)])
9a3f2acb55e6 Remove duplicate locations of catalog messages.
cmlenz
parents: 228
diff changeset
89 self.assertEqual([('foo.py', 1)], cat['foo'].locations)
9a3f2acb55e6 Remove duplicate locations of catalog messages.
cmlenz
parents: 228
diff changeset
90
277
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
91 def test_update_message_changed_to_plural(self):
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
92 cat = catalog.Catalog()
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
93 cat.add(u'foo', u'Voh')
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
94 tmpl = catalog.Catalog()
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
95 tmpl.add((u'foo', u'foos'))
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
96 cat.update(tmpl)
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
97 self.assertEqual((u'Voh', ''), cat['foo'].string)
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
98 assert cat['foo'].fuzzy
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
99
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
100 def test_update_message_changed_to_simple(self):
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
101 cat = catalog.Catalog()
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
102 cat.add((u'foo' u'foos'), (u'Voh', u'Vöhs'))
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
103 tmpl = catalog.Catalog()
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
104 tmpl.add(u'foo')
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
105 cat.update(tmpl)
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
106 self.assertEqual(u'Voh', cat['foo'].string)
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
107 assert cat['foo'].fuzzy
7a3f4ca113e4 Fix for updating catalog messages that changed from gettext to ngettext or vice versa.
cmlenz
parents: 230
diff changeset
108
89
5a456b7ebc0a Unittest for the problem reported by pjenvey fixed on [88].
palgarvio
parents: 80
diff changeset
109 def test_update_message_updates_comments(self):
5a456b7ebc0a Unittest for the problem reported by pjenvey fixed on [88].
palgarvio
parents: 80
diff changeset
110 cat = catalog.Catalog()
5a456b7ebc0a Unittest for the problem reported by pjenvey fixed on [88].
palgarvio
parents: 80
diff changeset
111 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 5)])
105
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
112 self.assertEqual(cat[u'foo'].auto_comments, [])
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
113 self.assertEqual(cat[u'foo'].user_comments, [])
89
5a456b7ebc0a Unittest for the problem reported by pjenvey fixed on [88].
palgarvio
parents: 80
diff changeset
114 # Update cat[u'foo'] with a new location and a comment
5a456b7ebc0a Unittest for the problem reported by pjenvey fixed on [88].
palgarvio
parents: 80
diff changeset
115 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 7)],
105
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
116 user_comments=['Foo Bar comment 1'])
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
117 self.assertEqual(cat[u'foo'].user_comments, ['Foo Bar comment 1'])
89
5a456b7ebc0a Unittest for the problem reported by pjenvey fixed on [88].
palgarvio
parents: 80
diff changeset
118 # now add yet another location with another comment
5a456b7ebc0a Unittest for the problem reported by pjenvey fixed on [88].
palgarvio
parents: 80
diff changeset
119 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 9)],
200
2983c718f6e2 Added `--no-fuzzy-matching` to the frontends and also `--previous` which adds the old msgid's as comments. The latest closes #31.
palgarvio
parents: 181
diff changeset
120 auto_comments=['Foo Bar comment 2'])
105
f744dd56573d `Message`, `read_po` and `write_po` now all handle user/auto comments correctly.
palgarvio
parents: 95
diff changeset
121 self.assertEqual(cat[u'foo'].auto_comments, ['Foo Bar comment 2'])
69
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
122
165
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
123 def test_update_fuzzy_matching_with_case_change(self):
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
124 cat = catalog.Catalog()
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
125 cat.add('foo', 'Voh')
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
126 cat.add('bar', 'Bahr')
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
127 tmpl = catalog.Catalog()
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
128 tmpl.add('Foo')
181
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 165
diff changeset
129 cat.update(tmpl)
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 165
diff changeset
130 self.assertEqual(1, len(cat.obsolete))
165
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
131 assert 'foo' not in cat
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
132
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
133 self.assertEqual('Voh', cat['Foo'].string)
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
134 self.assertEqual(True, cat['Foo'].fuzzy)
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
135
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
136 def test_update_fuzzy_matching_with_char_change(self):
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
137 cat = catalog.Catalog()
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
138 cat.add('fo', 'Voh')
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
139 cat.add('bar', 'Bahr')
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
140 tmpl = catalog.Catalog()
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
141 tmpl.add('foo')
181
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 165
diff changeset
142 cat.update(tmpl)
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 165
diff changeset
143 self.assertEqual(1, len(cat.obsolete))
165
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
144 assert 'fo' not in cat
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
145
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
146 self.assertEqual('Voh', cat['foo'].string)
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
147 self.assertEqual(True, cat['foo'].fuzzy)
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
148
312
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
149 def test_update_fuzzy_matching_no_msgstr(self):
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
150 cat = catalog.Catalog()
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
151 cat.add('fo', '')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
152 tmpl = catalog.Catalog()
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
153 tmpl.add('fo')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
154 tmpl.add('foo')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
155 cat.update(tmpl)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
156 assert 'fo' in cat
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
157 assert 'foo' in cat
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
158
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
159 self.assertEqual('', cat['fo'].string)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
160 self.assertEqual(False, cat['fo'].fuzzy)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
161 self.assertEqual(None, cat['foo'].string)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
162 self.assertEqual(False, cat['foo'].fuzzy)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
163
350
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
164 def test_update_fuzzy_matching_with_new_context(self):
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
165 cat = catalog.Catalog()
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
166 cat.add('foo', 'Voh')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
167 cat.add('bar', 'Bahr')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
168 tmpl = catalog.Catalog()
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
169 tmpl.add('Foo', context='Menu')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
170 cat.update(tmpl)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
171 self.assertEqual(1, len(cat.obsolete))
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
172 assert 'foo' not in cat
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
173
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
174 message = cat.get('Foo', 'Menu')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
175 self.assertEqual('Voh', message.string)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
176 self.assertEqual(True, message.fuzzy)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
177 self.assertEqual('Menu', message.context)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
178
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
179 def test_update_fuzzy_matching_with_changed_context(self):
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
180 cat = catalog.Catalog()
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
181 cat.add('foo', 'Voh', context='Menu|File')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
182 cat.add('bar', 'Bahr', context='Menu|File')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
183 tmpl = catalog.Catalog()
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
184 tmpl.add('Foo', context='Menu|Edit')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
185 cat.update(tmpl)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
186 self.assertEqual(1, len(cat.obsolete))
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
187 assert cat.get('Foo', 'Menu|File') is None
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
188
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
189 message = cat.get('Foo', 'Menu|Edit')
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
190 self.assertEqual('Voh', message.string)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
191 self.assertEqual(True, message.fuzzy)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
192 self.assertEqual('Menu|Edit', message.context)
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
193
312
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
194 def test_update_fuzzy_matching_no_cascading(self):
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
195 cat = catalog.Catalog()
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
196 cat.add('fo', 'Voh')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
197 cat.add('foo', 'Vohe')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
198 tmpl = catalog.Catalog()
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
199 tmpl.add('fo')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
200 tmpl.add('foo')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
201 tmpl.add('fooo')
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
202 cat.update(tmpl)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
203 assert 'fo' in cat
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
204 assert 'foo' in cat
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
205
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
206 self.assertEqual('Voh', cat['fo'].string)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
207 self.assertEqual(False, cat['fo'].fuzzy)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
208 self.assertEqual('Vohe', cat['foo'].string)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
209 self.assertEqual(False, cat['foo'].fuzzy)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
210 self.assertEqual('Vohe', cat['fooo'].string)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
211 self.assertEqual(True, cat['fooo'].fuzzy)
61e6b1933af4 Fix catalog updating with fuzzy matches. Closes #82.
cmlenz
parents: 277
diff changeset
212
165
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
213 def test_update_without_fuzzy_matching(self):
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
214 cat = catalog.Catalog()
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
215 cat.add('fo', 'Voh')
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
216 cat.add('bar', 'Bahr')
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
217 tmpl = catalog.Catalog()
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
218 tmpl.add('foo')
200
2983c718f6e2 Added `--no-fuzzy-matching` to the frontends and also `--previous` which adds the old msgid's as comments. The latest closes #31.
palgarvio
parents: 181
diff changeset
219 cat.update(tmpl, no_fuzzy_matching=True)
181
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 165
diff changeset
220 self.assertEqual(2, len(cat.obsolete))
165
650a6e996ede Implement fuzzy matching to catalog updates. No frontend yet.
cmlenz
parents: 111
diff changeset
221
425
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
222 def test_fuzzy_matching_regarding_plurals(self):
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
223 cat = catalog.Catalog()
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
224 cat.add(('foo', 'foh'), ('foo', 'foh'))
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
225 ru = copy.copy(cat)
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
226 ru.locale = 'ru_RU'
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
227 ru.update(cat)
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
228 self.assertEqual(True, ru['foo'].fuzzy)
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
229 ru = copy.copy(cat)
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
230 ru.locale = 'ru_RU'
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
231 ru['foo'].string = ('foh', 'fohh', 'fohhh')
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
232 ru.update(cat)
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
233 self.assertEqual(False, ru['foo'].fuzzy)
4c8a5e533722 Fuzzy matching regarding plurals should *NOT* be checked against `len(message.id)` because this is always 2, instead, it's should be checked against `catalog.num_plurals`.
palgarvio
parents: 422
diff changeset
234
313
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
235 def test_update_no_template_mutation(self):
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
236 tmpl = catalog.Catalog()
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
237 tmpl.add('foo')
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
238 cat1 = catalog.Catalog()
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
239 cat1.add('foo', 'Voh')
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
240 cat1.update(tmpl)
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
241 cat2 = catalog.Catalog()
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
242 cat2.update(tmpl)
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
243
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
244 self.assertEqual(None, cat2['foo'].string)
559c80b1ffb2 Merging catalogs would sometimes mix translations from different runs.
cmlenz
parents: 312
diff changeset
245 self.assertEqual(False, cat2['foo'].fuzzy)
419
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
246
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
247 def test_update_po_updates_pot_creation_date(self):
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
248 template = catalog.Catalog()
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
249 localized_catalog = copy.deepcopy(template)
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
250 localized_catalog.locale = 'de_DE'
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
251 self.assertNotEqual(template.mime_headers,
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
252 localized_catalog.mime_headers)
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
253 self.assertEqual(template.creation_date,
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
254 localized_catalog.creation_date)
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
255 template.creation_date = datetime.datetime.now() - \
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
256 datetime.timedelta(minutes=5)
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
257 localized_catalog.update(template)
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
258 self.assertEqual(template.creation_date,
b44a5936a889 Testcase for fix of #148.
palgarvio
parents: 359
diff changeset
259 localized_catalog.creation_date)
422
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
260
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
261 def test_update_po_keeps_po_revision_date(self):
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
262 template = catalog.Catalog()
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
263 localized_catalog = copy.deepcopy(template)
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
264 localized_catalog.locale = 'de_DE'
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
265 fake_rev_date = datetime.datetime.now() - datetime.timedelta(days=5)
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
266 localized_catalog.revision_date = fake_rev_date
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
267 self.assertNotEqual(template.mime_headers,
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
268 localized_catalog.mime_headers)
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
269 self.assertEqual(template.creation_date,
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
270 localized_catalog.creation_date)
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
271 template.creation_date = datetime.datetime.now() - \
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
272 datetime.timedelta(minutes=5)
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
273 localized_catalog.update(template)
3dd226bb3ec3 Final and complete fix for #148.
palgarvio
parents: 419
diff changeset
274 self.assertEqual(localized_catalog.revision_date, fake_rev_date)
69
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
275
427
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
276 def test_stores_datetime_correctly(self):
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
277 localized = catalog.Catalog()
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
278 localized.locale = 'de_DE'
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
279 localized[''] = catalog.Message('',
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
280 "POT-Creation-Date: 2009-03-09 15:47-0700\n" +
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
281 "PO-Revision-Date: 2009-03-09 15:47-0700\n")
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
282 for key, value in localized.mime_headers:
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
283 if key in ('POT-Creation-Date', 'PO-Revision-Date'):
912e21ea527d Fix Catalog._set_mime_headers' handing of negative offsets.
jruigrok
parents: 425
diff changeset
284 self.assertEqual(value, '2009-03-09 15:47-0700')
350
24b8e5ca7a76 More work on msgctxt support (#54).
cmlenz
parents: 313
diff changeset
285
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
286 def suite():
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
287 suite = unittest.TestSuite()
466
330e91b7feb2 Fix test to run under Python 2.3.
jruigrok
parents: 427
diff changeset
288 if hasattr(doctest, 'ELLIPSIS'):
330e91b7feb2 Fix test to run under Python 2.3.
jruigrok
parents: 427
diff changeset
289 suite.addTest(doctest.DocTestSuite(catalog, optionflags=doctest.ELLIPSIS))
330e91b7feb2 Fix test to run under Python 2.3.
jruigrok
parents: 427
diff changeset
290 else:
330e91b7feb2 Fix test to run under Python 2.3.
jruigrok
parents: 427
diff changeset
291 suite.addTest(doctest.DocTestSuite(catalog))
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
292 suite.addTest(unittest.makeSuite(MessageTestCase))
69
9b8079807245 Message catalogs can have multiple messages with the same ID, where some of them have plural strings, and others don't. Still the same message.
cmlenz
parents: 67
diff changeset
293 suite.addTest(unittest.makeSuite(CatalogTestCase))
56
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
294 return suite
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
295
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
296 if __name__ == '__main__':
27fba894d3ca Add actual data structures for handling message catalogs, so that more code can be reused here between the frontends.
cmlenz
parents:
diff changeset
297 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software