test_pre_processors.py 798 B

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. import unittest
  3. from gtts.tokenizer.pre_processors import (
  4. tone_marks,
  5. end_of_line,
  6. abbreviations,
  7. word_sub,
  8. )
  9. class TestPreProcessors(unittest.TestCase):
  10. def test_tone_marks(self):
  11. _in = "lorem!ipsum?"
  12. _out = "lorem! ipsum? "
  13. self.assertEqual(tone_marks(_in), _out)
  14. def test_end_of_line(self):
  15. _in = """test-
  16. ing"""
  17. _out = "testing"
  18. self.assertEqual(end_of_line(_in), _out)
  19. def test_abbreviations(self):
  20. _in = "jr. sr. dr."
  21. _out = "jr sr dr"
  22. self.assertEqual(abbreviations(_in), _out)
  23. def test_word_sub(self):
  24. _in = "Esq. Bacon"
  25. _out = "Esquire Bacon"
  26. self.assertEqual(word_sub(_in), _out)
  27. if __name__ == "__main__":
  28. unittest.main()