import osimport sysimport unittestfrom stringBundle import StringBundleclass TestStringBundle(unittest.TestCase):def test_loadDefaultBundle_withoutError(self):strBundle = StringBundle.getBundle('en')self.assertEqual(strBundle.getString("openDir"), 'Open Dir', 'Fail to load the default bundle')def test_fallback_withoutError(self):strBundle = StringBundle.getBundle('zh-TW')self.assertEqual(strBundle.getString("openDir"), u'\u958B\u555F\u76EE\u9304', 'Fail to load the zh-TW bundle')def test_setInvaleLocaleToEnv_printErrorMsg(self):prev_lc = os.environ['LC_ALL']prev_lang = os.environ['LANG']os.environ['LC_ALL'] = 'UTF-8'os.environ['LANG'] = 'UTF-8'strBundle = StringBundle.getBundle()self.assertEqual(strBundle.getString("openDir"), 'Open Dir', 'Fail to load the default bundle')os.environ['LC_ALL'] = prev_lcos.environ['LANG'] = prev_langif __name__ == '__main__':unittest.main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。