MCPcopy Index your code
hub / github.com/python/cpython / test_nested_fallbacks

Method test_nested_fallbacks

Lib/test/test_gettext.py:816–831  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

814 'npgettext: context, foo, foos, 1')
815
816 def test_nested_fallbacks(self):
817 class NestedFallback(gettext.NullTranslations):
818 def gettext(self, message):
819 if message == 'foo':
820 return 'fallback'
821 return super().gettext(message)
822
823 fallback1 = NestedFallback()
824 fallback2 = FallbackTranslations()
825 t = gettext.NullTranslations()
826 t.add_fallback(fallback1)
827 t.add_fallback(fallback2)
828
829 self.assertEqual(fallback1.gettext('bar'), 'gettext: bar')
830 self.assertEqual(t.gettext('foo'), 'fallback')
831 self.assertEqual(t.gettext('bar'), 'gettext: bar')
832
833
834class ExpandLangTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 6

add_fallbackMethod · 0.95
gettextMethod · 0.95
gettextMethod · 0.95
NestedFallbackClass · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected