test_pdf2text_recogPara_BlockContinuationProcessor.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import unittest
  2. from magic_pdf.post_proc.detect_para import BlockContinuationProcessor
  3. # from ... pdf2text_recogPara import BlockContinuationProcessor # another way to import
  4. """
  5. Execute the following command to run the test under directory code-clean:
  6. python -m tests.test_para.test_pdf2text_recogPara_ClassName
  7. or
  8. pytest -v -s app/pdf_toolbox/tests/test_para/test_pdf2text_recogPara_BlockContinuationProcessor.py
  9. """
  10. class TestIsAlphabetChar(unittest.TestCase):
  11. def setUp(self):
  12. self.obj = BlockContinuationProcessor()
  13. def test_is_alphabet_char(self):
  14. char = "A"
  15. result = self.obj._is_alphabet_char(char)
  16. self.assertTrue(result)
  17. def test_is_not_alphabet_char(self):
  18. char = "1"
  19. result = self.obj._is_alphabet_char(char)
  20. self.assertFalse(result)
  21. class TestIsChineseChar(unittest.TestCase):
  22. def setUp(self):
  23. self.obj = BlockContinuationProcessor()
  24. def test_is_chinese_char(self):
  25. char = "中"
  26. result = self.obj._is_chinese_char(char)
  27. self.assertTrue(result)
  28. def test_is_not_chinese_char(self):
  29. char = "A"
  30. result = self.obj._is_chinese_char(char)
  31. self.assertFalse(result)
  32. class TestIsOtherLetterChar(unittest.TestCase):
  33. def setUp(self):
  34. self.obj = BlockContinuationProcessor()
  35. def test_is_other_letter_char(self):
  36. char = "Ä"
  37. result = self.obj._is_other_letter_char(char)
  38. self.assertTrue(result)
  39. def test_is_not_other_letter_char(self):
  40. char = "A"
  41. result = self.obj._is_other_letter_char(char)
  42. self.assertFalse(result)
  43. if __name__ == "__main__":
  44. unittest.main()