]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
update Translations.load to use new parameter name ('fp' instead of 'fileobj'), regre...
authorFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Wed, 22 Aug 2012 20:28:32 +0000 (20:28 +0000)
committerFelix Schwarz <felix.schwarz@oss.schwarz.eu>
Wed, 22 Aug 2012 20:28:32 +0000 (20:28 +0000)
babel/support.py
babel/tests/support.py

index 6c6ebf456d7753c8cf3e586c8b95e999f4e1abab..eeac110d116c0ea85d99ff886c1e86717917c99b 100644 (file)
@@ -555,7 +555,7 @@ class Translations(NullTranslations, gettext.GNUTranslations):
         filename = gettext.find(domain, dirname, locales)
         if not filename:
             return NullTranslations()
-        return cls(fileobj=open(filename, 'rb'), domain=domain)
+        return cls(fp=open(filename, 'rb'), domain=domain)
 
     def __repr__(self):
         return '<%s: "%s">' % (type(self).__name__,
index 5b1b5655b597ae3035bdc461b9733074e11aa5c6..cf006a955dd1c857e8a3a4f0a217c87c41f8e45b 100644 (file)
@@ -14,7 +14,9 @@
 import doctest
 import inspect
 import os
+import shutil
 from StringIO import StringIO
+import tempfile
 import unittest
 
 from babel import support
@@ -163,6 +165,20 @@ class TranslationsTestCase(unittest.TestCase):
         self.assertEqualTypeToo(
             'VohsCTXD1', self.translations.ldnpgettext('messages1', 'foo', 'foo1',
                                                        'foos1', 2))
+   
+    def test_load(self):
+        tempdir = tempfile.mkdtemp()
+        try:
+            messages_dir = os.path.join(tempdir, 'fr', 'LC_MESSAGES')
+            os.makedirs(messages_dir)
+            catalog = Catalog(locale='fr', domain='messages')
+            catalog.add('foo', 'bar')
+            write_mo(file(os.path.join(messages_dir, 'messages.mo'), 'wb'), catalog)
+            
+            translations = support.Translations.load(tempdir, locales=('fr',), domain='messages')
+            self.assertEqual('bar', translations.gettext('foo'))
+        finally:
+            shutil.rmtree(tempdir)
 
 
 class NullTranslationsTestCase(unittest.TestCase):