comparison babel/messages/tests/catalog.py @ 167:533baef258bb

Implement fuzzy matching to catalog updates. No frontend yet.
author cmlenz
date Fri, 22 Jun 2007 08:39:04 +0000
parents 0c18f72fcb76
children e927dffc9ab4
comparison
equal deleted inserted replaced
166:0eccbe635dba 167:533baef258bb
54 # now add yet another location with another comment 54 # now add yet another location with another comment
55 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 9)], 55 cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 9)],
56 auto_comments=['Foo Bar comment 2']) 56 auto_comments=['Foo Bar comment 2'])
57 self.assertEqual(cat[u'foo'].auto_comments, ['Foo Bar comment 2']) 57 self.assertEqual(cat[u'foo'].auto_comments, ['Foo Bar comment 2'])
58 58
59 def test_update_fuzzy_matching_with_case_change(self):
60 cat = catalog.Catalog()
61 cat.add('foo', 'Voh')
62 cat.add('bar', 'Bahr')
63 tmpl = catalog.Catalog()
64 tmpl.add('Foo')
65 rest = cat.update(tmpl)
66 self.assertEqual(1, len(rest))
67 assert 'foo' not in cat
68
69 self.assertEqual('Voh', cat['Foo'].string)
70 self.assertEqual(True, cat['Foo'].fuzzy)
71
72 def test_update_fuzzy_matching_with_char_change(self):
73 cat = catalog.Catalog()
74 cat.add('fo', 'Voh')
75 cat.add('bar', 'Bahr')
76 tmpl = catalog.Catalog()
77 tmpl.add('foo')
78 rest = cat.update(tmpl)
79 self.assertEqual(1, len(rest))
80 assert 'fo' not in cat
81
82 self.assertEqual('Voh', cat['foo'].string)
83 self.assertEqual(True, cat['foo'].fuzzy)
84
85 def test_update_without_fuzzy_matching(self):
86 cat = catalog.Catalog()
87 cat.add('fo', 'Voh')
88 cat.add('bar', 'Bahr')
89 tmpl = catalog.Catalog()
90 tmpl.add('foo')
91 rest = cat.update(tmpl, fuzzy_matching=False)
92 self.assertEqual(2, len(rest))
93
59 94
60 def suite(): 95 def suite():
61 suite = unittest.TestSuite() 96 suite = unittest.TestSuite()
62 suite.addTest(doctest.DocTestSuite(catalog, optionflags=doctest.ELLIPSIS)) 97 suite.addTest(doctest.DocTestSuite(catalog, optionflags=doctest.ELLIPSIS))
63 suite.addTest(unittest.makeSuite(MessageTestCase)) 98 suite.addTest(unittest.makeSuite(MessageTestCase))
Copyright (C) 2012-2017 Edgewall Software