You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.3 KiB

  1. import os
  2. import unittest
  3. import json
  4. from collections import OrderedDict
  5. from gooey import languages
  6. from gooey.gui.processor import ProcessController
  7. class TestLanguageParity(unittest.TestCase):
  8. """
  9. Checks that all language files have the same set of keys so that non-english
  10. languages don't silently break as features are added to Gooey.
  11. """
  12. def test_languageParity(self):
  13. langDir = os.path.dirname(languages.__file__)
  14. englishFile = os.path.join(langDir, 'english.json')
  15. english = self.readFile(englishFile)
  16. jsonFiles = [(path, self.readFile(os.path.join(langDir, path)))
  17. for path in os.listdir(langDir)
  18. if path.endswith('json') and 'poooo' not in path and '2' not in path]
  19. allKeys = set(english.keys())
  20. for name, contents in jsonFiles:
  21. missing = allKeys.difference(set(contents.keys()))
  22. self.assertEqual(
  23. set(),
  24. missing,
  25. "{} language file is missing keys: [{}]".format(name, missing)
  26. )
  27. def readFile(self, path):
  28. with open(path, 'r', encoding='utf-8') as f:
  29. return json.loads(f.read())
  30. if __name__ == '__main__':
  31. unittest.main()