test04_normalization.py 776 B

123456789101112131415161718192021222324252627282930
  1. from csv import reader
  2. from os import environ, path, unlink
  3. from unittest import TestCase
  4. from scriptshifter.trans import Transliterator, FEAT_R2S
  5. from scriptshifter.tables import init_db
  6. from test import TEST_DATA_DIR
  7. def setUpModule():
  8. init_db()
  9. def tearDownModule():
  10. unlink(environ["TXL_DB_PATH"])
  11. class TestNormalization(TestCase):
  12. """ Source normalization tests. """
  13. def test_norm_decompose_r2s(self):
  14. with open(path.join(
  15. TEST_DATA_DIR, "precomp_samples.csv"), newline="") as fh:
  16. data = reader(fh)
  17. for precomp, decomp in data:
  18. with Transliterator("rot3", precomp, FEAT_R2S, {}) as ctx:
  19. ctx.normalize_src()
  20. self.assertEqual(ctx.src, decomp)