-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtest_languages.py
45 lines (31 loc) · 1.17 KB
/
test_languages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import importlib
import pkgutil
import re
import unittest
import languages
import languages.en_US
class TestLanguages(unittest.TestCase):
def setUp(self):
self.english_keys = list(languages.en_US.local_str.keys())
def test_languages_against_english(self):
for language in pkgutil.iter_modules(languages.__path__):
if language.name == 'en_US':
continue
print(f'Checking locale {language.name}')
lang_module = importlib.import_module(f'languages.{language.name}')
self.assertListEqual(
self.english_keys,
list(lang_module.local_str.keys()),
)
self.assertTrue(all([
isinstance(val, str)
for val in lang_module.local_str.values()
]))
def test_local_str_references_in_main_script(self):
with open('davinci-resolve-checker.py', 'r') as file:
main_script = file.read()
matches = re.finditer('local_str\["([^\".]+)"\]', main_script)
for match in matches:
self.assertIn(match.groups()[0], self.english_keys)
if __name__ == '__main__':
unittest.main()