summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_gettext.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2010-10-04 23:52:37 (GMT)
committerÉric Araujo <merwok@netwok.org>2010-10-04 23:52:37 (GMT)
commit6108bf5ed002925f2092deb025f336d8c2024299 (patch)
tree1e2c4f8c7329edab6adb0247528da28607818141 /Lib/test/test_gettext.py
parent701761693c7f6a2d748e43ae70f46e371087a864 (diff)
downloadcpython-6108bf5ed002925f2092deb025f336d8c2024299.zip
cpython-6108bf5ed002925f2092deb025f336d8c2024299.tar.gz
cpython-6108bf5ed002925f2092deb025f336d8c2024299.tar.bz2
Fix interaction of custom translation classes and caching (#9042)
Diffstat (limited to 'Lib/test/test_gettext.py')
-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__)