diff options
author | Thomas Herve <therve@redhat.com> | 2018-10-22 14:27:35 +0200 |
---|---|---|
committer | Thomas Herve <therve@redhat.com> | 2018-11-21 14:45:52 +0100 |
commit | a5fde9a90a8216f70129c20d348f1f615b8842f3 (patch) | |
tree | a06093eb340e09780d36148dfb2b58e263176153 /oslo_i18n/tests/test_gettextutils.py | |
parent | 89a48dfadc964f781d86ea1c43bfd4319c316466 (diff) | |
download | oslo-i18n-a5fde9a90a8216f70129c20d348f1f615b8842f3.tar.gz |
Override getttext.find to cache result3.23.0
This monkey patches gettext to cache the results of gettext.find. This
allows to drastically reduces system calls made over time for checking
the existence of mo files, which don't move.
Change-Id: I1464f131b90123aab67ef45ae2a2685a3ba111ef
Diffstat (limited to 'oslo_i18n/tests/test_gettextutils.py')
-rw-r--r-- | oslo_i18n/tests/test_gettextutils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/oslo_i18n/tests/test_gettextutils.py b/oslo_i18n/tests/test_gettextutils.py index 6a30a95..2eca069 100644 --- a/oslo_i18n/tests/test_gettextutils.py +++ b/oslo_i18n/tests/test_gettextutils.py @@ -129,3 +129,13 @@ class GettextTest(test_base.BaseTestCase): unknown_domain_languages = _gettextutils.get_available_languages('huh') self.assertEqual(1, len(unknown_domain_languages)) self.assertIn('en_US', unknown_domain_languages) + + def test_cached_find(self): + domain = 'my-unique-domain' + key = (domain, None, None, 0) + self.assertNotIn(key, _gettextutils._FIND_CACHE) + gettext.find(domain) + self.assertIn(key, _gettextutils._FIND_CACHE) + _gettextutils._FIND_CACHE[key] = "spoof result" + self.assertEqual("spoof result", gettext.find(domain)) + _gettextutils._FIND_CACHE.pop(key) |