greenhouse/labelImg/tests/test_stringBundle.py
apoorva a52800deb9 Add 'labelImg/' from commit 'b33f965b6d14c14f1e46b247f1bf346e03f2e950'
git-subtree-dir: labelImg
git-subtree-mainline: dbe80aca780253f6ee1e5a2f8686407ca179e921
git-subtree-split: b33f965b6d14c14f1e46b247f1bf346e03f2e950
2023-02-21 21:52:18 +05:30

30 lines
1.0 KiB
Python

import os
import sys
import unittest
import resources
from stringBundle import StringBundle
class TestStringBundle(unittest.TestCase):
def test_loadDefaultBundle_withoutError(self):
str_bundle = StringBundle.get_bundle('en')
self.assertEqual(str_bundle.get_string("openDir"), 'Open Dir', 'Fail to load the default bundle')
def test_fallback_withoutError(self):
str_bundle = StringBundle.get_bundle('zh-TW')
self.assertEqual(str_bundle.get_string("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'
str_bundle = StringBundle.get_bundle()
self.assertEqual(str_bundle.get_string("openDir"), 'Open Dir', 'Fail to load the default bundle')
os.environ['LC_ALL'] = prev_lc
os.environ['LANG'] = prev_lang
if __name__ == '__main__':
unittest.main()