|
@@ -6,7 +6,7 @@ from json import loads as jloads
|
|
from os import environ, path, unlink
|
|
from os import environ, path, unlink
|
|
|
|
|
|
from scriptshifter.trans import transliterate
|
|
from scriptshifter.trans import transliterate
|
|
-from scriptshifter.tables import get_language
|
|
|
|
|
|
+from scriptshifter.tables import get_language, init_db
|
|
from tests import TEST_DATA_DIR
|
|
from tests import TEST_DATA_DIR
|
|
|
|
|
|
|
|
|
|
@@ -14,7 +14,6 @@ logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
def setUpModule():
|
|
def setUpModule():
|
|
- from scriptshifter.tables import init_db
|
|
|
|
init_db()
|
|
init_db()
|
|
|
|
|
|
|
|
|
|
@@ -31,12 +30,9 @@ class TestTrans(TestCase):
|
|
TODO use a comprehensive sample table and report errors for unsupported
|
|
TODO use a comprehensive sample table and report errors for unsupported
|
|
languages.
|
|
languages.
|
|
"""
|
|
"""
|
|
-
|
|
|
|
- maxDiff = None
|
|
|
|
-
|
|
|
|
- def sample_s2r(self):
|
|
|
|
|
|
+ def sample(self):
|
|
"""
|
|
"""
|
|
- Test S2R transliteration for one CSV sample.
|
|
|
|
|
|
+ Test transliteration for one CSV row.
|
|
|
|
|
|
This function name won't start with `test_` otherwise will be
|
|
This function name won't start with `test_` otherwise will be
|
|
automatically run without parameters.
|
|
automatically run without parameters.
|
|
@@ -45,6 +41,7 @@ class TestTrans(TestCase):
|
|
if config["has_s2r"]:
|
|
if config["has_s2r"]:
|
|
txl = transliterate(
|
|
txl = transliterate(
|
|
self.script, self.tbl,
|
|
self.script, self.tbl,
|
|
|
|
+ t_dir=self.options.get("t_dir", "s2r"),
|
|
capitalize=self.options.get("capitalize", False),
|
|
capitalize=self.options.get("capitalize", False),
|
|
options=self.options)[0]
|
|
options=self.options)[0]
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
@@ -52,25 +49,6 @@ class TestTrans(TestCase):
|
|
f"S2R transliteration error for {self.tbl}!\n"
|
|
f"S2R transliteration error for {self.tbl}!\n"
|
|
f"Original: {self.script}")
|
|
f"Original: {self.script}")
|
|
|
|
|
|
- def sample_r2s(self):
|
|
|
|
- """
|
|
|
|
- Test R2S transliteration for one CSV sample.
|
|
|
|
-
|
|
|
|
- This function name won't start with `test_` otherwise will be
|
|
|
|
- automatically run without parameters.
|
|
|
|
- """
|
|
|
|
- config = get_language(self.tbl)
|
|
|
|
- if config["has_r2s"]:
|
|
|
|
- txl = transliterate(
|
|
|
|
- self.roman, self.tbl,
|
|
|
|
- t_dir="r2s",
|
|
|
|
- capitalize=self.options.get("capitalize", False),
|
|
|
|
- options=self.options)[0]
|
|
|
|
- self.assertEqual(
|
|
|
|
- txl, self.script,
|
|
|
|
- f"R2S transliteration error for {self.tbl}!\n"
|
|
|
|
- f"Original: {self.roman}")
|
|
|
|
-
|
|
|
|
|
|
|
|
def make_suite():
|
|
def make_suite():
|
|
"""
|
|
"""
|
|
@@ -85,13 +63,13 @@ def make_suite():
|
|
for row in csv:
|
|
for row in csv:
|
|
if len(row[0]):
|
|
if len(row[0]):
|
|
# Inject transliteration info in the test case.
|
|
# Inject transliteration info in the test case.
|
|
- for tname in ("sample_s2r", "sample_r2s"):
|
|
|
|
- tcase = TestTrans(tname)
|
|
|
|
- tcase.tbl = row[0]
|
|
|
|
- tcase.script = row[1].strip()
|
|
|
|
- tcase.roman = row[2].strip()
|
|
|
|
- tcase.options = jloads(row[3]) if len(row[3]) else {}
|
|
|
|
- suite.addTest(tcase)
|
|
|
|
|
|
+ tcase = TestTrans("sample")
|
|
|
|
+ tcase.tbl = row[0]
|
|
|
|
+ tcase.script = row[1].strip()
|
|
|
|
+ tcase.roman = row[2].strip()
|
|
|
|
+ tcase.options = jloads(row[3]) if len(row[3]) else {}
|
|
|
|
+
|
|
|
|
+ suite.addTest(tcase)
|
|
|
|
|
|
return suite
|
|
return suite
|
|
|
|
|