diff babel/messages/tests/pofile.py @ 175:5d32098d8352 trunk

Changed the `__repr__` output to include the flags(it can be changed back, but it was usefull to implement the fuzzy header parsing). The `Catalog` class now also includes an extra attribute, '''`fuzzy`''', which is the fuzzy bit of the catalog header. The above change allows the `compile_catalog` frontends to only compile catalogs '''not''' marked as fuzzy, unless `--use-fuzzy` is passed. Added tests to check header fuzzy bit parsing.
author palgarvio
date Tue, 26 Jun 2007 16:46:56 +0000
parents 2cd83f77cc98
children 8a762ce37bf7
line wrap: on
line diff
--- a/babel/messages/tests/pofile.py
+++ b/babel/messages/tests/pofile.py
@@ -35,6 +35,33 @@
         self.assertEqual("Here's some text that\nincludesareallylongwordthat"
                          "mightbutshouldnt throw us into an infinite loop\n",
                          message.id)
+        
+    def test_fuzzy_header(self):
+        buf = StringIO(r'''\
+# Translations template for AReallyReallyLongNameForAProject.
+# Copyright (C) 2007 ORGANIZATION
+# This file is distributed under the same license as the
+# AReallyReallyLongNameForAProject project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
+#
+#, fuzzy
+''')
+        catalog = pofile.read_po(buf)
+        self.assertEqual(1, len(list(catalog)))
+        self.assertEqual(True, list(catalog)[0].fuzzy)
+        
+    def test_not_fuzzy_header(self):
+        buf = StringIO(r'''\
+# Translations template for AReallyReallyLongNameForAProject.
+# Copyright (C) 2007 ORGANIZATION
+# This file is distributed under the same license as the
+# AReallyReallyLongNameForAProject project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
+#
+''')
+        catalog = pofile.read_po(buf)
+        self.assertEqual(1, len(list(catalog)))
+        self.assertEqual(False, list(catalog)[0].fuzzy)
 
 
 class WritePoTestCase(unittest.TestCase):
Copyright (C) 2012-2017 Edgewall Software