]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Recognize python-format messages also for unnamed parameters.
authorChristopher Lenz <cmlenz@gmail.com>
Thu, 31 May 2007 17:07:49 +0000 (17:07 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Thu, 31 May 2007 17:07:49 +0000 (17:07 +0000)
babel/catalog/pofile.py
babel/catalog/tests/pofile.py

index 966ddaf61704b457eace1f05db67f8f273ab4d8d..0a05fa28889a65ec88216b926710aeb59bfcf5be 100644 (file)
@@ -51,7 +51,7 @@ msgstr ""
 
 """ % VERSION
 
-PYTHON_FORMAT = re.compile(r'(\%\(([\w]+)\)[diouxXeEfFgGcrs])').search
+PYTHON_FORMAT = re.compile(r'\%(\([\w]+\))?[diouxXeEfFgGcrs]').search
 
 def escape(string):
     r"""Escape the given string so that it can be included in double-quoted
index 7152df3aab93fafbdb2ddefce3a1180afb020a06..b0f08e77f461877673c9dfc569e9596238e28d4b 100644 (file)
@@ -16,9 +16,19 @@ import unittest
 
 from babel.catalog import pofile
 
+
+class PythonFormatFlagUnitTest(unittest.TestCase):
+
+    def test_without_name(self):
+        assert pofile.PYTHON_FORMAT('foo %d bar')
+        assert pofile.PYTHON_FORMAT('foo %s bar')
+        assert pofile.PYTHON_FORMAT('foo %r bar')
+
+
 def suite():
     suite = unittest.TestSuite()
     suite.addTest(doctest.DocTestSuite(pofile))
+    suite.addTest(unittest.makeSuite(PythonFormatFlagUnitTest))
     return suite
 
 if __name__ == '__main__':