summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2010-10-04 23:57:46 (GMT)
committerÉric Araujo <merwok@netwok.org>2010-10-04 23:57:46 (GMT)
commit298be5161f27006a82bf499fcd7a990cb5ee4a87 (patch)
tree6c262cb543dd39ce972d12e19f0f17e45c32f67a /Lib/test
parent2fdbfc507e0a2e2b92415bf5a25090a6839ae799 (diff)
downloadcpython-298be5161f27006a82bf499fcd7a990cb5ee4a87.zip
cpython-298be5161f27006a82bf499fcd7a990cb5ee4a87.tar.gz
cpython-298be5161f27006a82bf499fcd7a990cb5ee4a87.tar.bz2
Merged revisions 85223 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85223 | eric.araujo | 2010-10-05 01:52:37 +0200 (mar., 05 oct. 2010) | 3 lines Fix interaction of custom translation classes and caching (#9042) ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_gettext.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index d667819..69ffcb7 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -335,6 +335,37 @@ class WeirdMetadataTest(GettextBaseTest):
'John Doe <jdoe@example.com>\nJane Foobar <jfoobar@example.com>')
+class DummyGNUTranslations(gettext.GNUTranslations):
+ def foo(self):
+ return 'foo'
+
+
+class GettextCacheTestCase(GettextBaseTest):
+ def test_cache(self):
+ self.localedir = os.curdir
+ self.mofile = MOFILE
+
+ self.assertEqual(len(gettext._translations), 0)
+
+ t = gettext.translation('gettext', self.localedir)
+
+ self.assertEqual(len(gettext._translations), 1)
+
+ t = gettext.translation('gettext', self.localedir,
+ class_=DummyGNUTranslations)
+
+ self.assertEqual(len(gettext._translations), 2)
+ self.assertEqual(t.__class__, DummyGNUTranslations)
+
+ # Calling it again doesn't add to the cache
+
+ t = gettext.translation('gettext', self.localedir,
+ class_=DummyGNUTranslations)
+
+ self.assertEqual(len(gettext._translations), 2)
+ self.assertEqual(t.__class__, DummyGNUTranslations)
+
+
def test_main():
support.run_unittest(__name__)