test_parsable.py 686 B

12345678910111213141516171819202122
  1. from gflanguages import DATA_DIR
  2. import glob
  3. import os
  4. import pytest
  5. from gflanguages import languages_public_pb2
  6. from google.protobuf import text_format
  7. languages_dir = os.path.join(DATA_DIR, "languages")
  8. textproto_files = [
  9. os.path.basename(x) for x in glob.iglob(os.path.join(languages_dir, "*.textproto"))
  10. ]
  11. @pytest.mark.parametrize("lang_code", textproto_files)
  12. def test_parsable(lang_code):
  13. with open(os.path.join(languages_dir, lang_code), "r", encoding="utf-8") as f:
  14. msg = text_format.Parse(f.read(), languages_public_pb2.LanguageProto())
  15. assert msg.id
  16. assert msg.language
  17. assert msg.script
  18. assert msg.population is not None