def testGetTextMsg1Reset(self): self._addLocaleDir("locale1") device = _Device() self.failUnlessEqual(locale.gettext(_MSG1_ID, device), _TRANS1) self.failUnlessEqual(locale.gettext(_MSG2_ID, device), _MSG2_ID) locale.reset() self.failUnlessEqual(locale.gettext(_MSG1_ID, device), _TRANS1) self.failUnlessEqual(locale.gettext(_MSG2_ID, device), _MSG2_ID)
def testGetTextMsg12Remove1(self): self._addLocaleDir("locale1") self._addLocaleDir("locale2") device = _Device() self.failUnlessEqual(locale.gettext(_MSG1_ID, device), _TRANS1) self.failUnlessEqual(locale.gettext(_MSG2_ID, device), _TRANS2) self._removeLocaleDir("locale1") self.failUnlessEqual(locale.gettext(_MSG1_ID, device), _MSG1_ID) self.failUnlessEqual(locale.gettext(_MSG2_ID, device), _TRANS2)
def testNoLocalePath(self): device = _Device() self.failUnlessEqual(locale.gettext(_MSG1_ID, device), _MSG1_ID) self.failUnlessEqual(locale.gettext(_MSG2_ID, device), _MSG2_ID)
def testGetTextMsg2LazyGetText(self): self._addLocaleDir("locale2") device = _Device() msg = locale.gettext__(_MSG2_ID) self.failUnless(isinstance(msg, locale.LazyTranslation)) self.failUnlessEqual(locale.gettext(msg, device), _TRANS2)
def testGetTextMsg1EmptyLocale(self): self._addLocaleDir("locale1") device = _Device() device.locale = '' self.failUnlessEqual(locale.gettext(_MSG1_ID, device), _MSG1_ID)
def testGetTextTranslatedMsg1(self): self._addLocaleDir("locale1") self._addLocaleDir("locale2") self._addLocaleDir("locale3") device = _Device() self.failUnlessEqual(locale.gettext(_TRANS1, device), _TRANS1)
def testGetTextMsg12Fail(self): self._addLocaleDir("locale3") device = _Device() self.failUnlessEqual(locale.gettext(_MSG1_ID, device), _MSG1_ID) self.failUnlessEqual(locale.gettext(_MSG2_ID, device), _MSG2_ID)