Skip to content

Commit

Permalink
test: add a test case for generate-mapping --ipa
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Sep 7, 2023
1 parent 205c3f1 commit 482fbc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion g2p/mappings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Rule(BaseModel):
"""Whether to prevent the rule from feeding other rules"""

match_pattern: Optional[Pattern] = None
"""An automatically generated match_pattern basec on the rule_input, context_before and context_after"""
"""An automatically generated match_pattern based on the rule_input, context_before and context_after"""

intermediate_form: Optional[str] = None
"""An optional intermediate form. Should be automatically generated only when prevent_feeding is True"""
Expand Down
14 changes: 14 additions & 0 deletions g2p/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

import json
import os
import re
import shutil
Expand Down Expand Up @@ -441,6 +442,19 @@ def test_short_dash_h(self):
self.assertEqual(results_long.exit_code, 0)
self.assertEqual(results_short.output, results_long.output)

def test_generate_mapping(self):
with tempfile.TemporaryDirectory() as tmpdir:
result = self.runner.invoke(
generate_mapping, ["--ipa", "--out-dir", tmpdir, "fra"]
)
self.assertEqual(result.exit_code, 0)
with open(
os.path.join(tmpdir, "fra-ipa_to_eng-ipa.json"), "r", encoding="utf8"
) as f:
fra2eng_ipa = json.load(f)
for s in ("ɛj", "ks", "ɔn"):
self.assertIn({"in": s, "out": s}, fra2eng_ipa)


if __name__ == "__main__":
main()

0 comments on commit 482fbc6

Please sign in to comment.