]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
Test to ensure all textprotos can be parsed
authorSimon Cozens <simon@simon-cozens.org>
Fri, 24 Mar 2023 10:08:27 +0000 (10:08 +0000)
committerSimon Cozens <simon@simon-cozens.org>
Fri, 24 Mar 2023 10:08:27 +0000 (10:08 +0000)
tests/test_parsable.py [new file with mode: 0644]

diff --git a/tests/test_parsable.py b/tests/test_parsable.py
new file mode 100644 (file)
index 0000000..8f32a2e
--- /dev/null
@@ -0,0 +1,15 @@
+from gflanguages import DATA_DIR
+import glob
+import os
+import pytest
+from gflanguages import languages_public_pb2
+from google.protobuf import text_format
+
+
+languages_dir = os.path.join(DATA_DIR, "languages")
+textproto_files = [os.path.basename(x) for x in glob.iglob(os.path.join(languages_dir, "*.textproto"))]
+
+@pytest.mark.parametrize("lang_code", textproto_files)
+def test_parsable(lang_code):
+    with open(os.path.join(languages_dir, lang_code), "r", encoding="utf-8") as f:
+        text_format.Parse(f.read(), languages_public_pb2.LanguageProto())