test_pdf2text_recogPara_BlockContinuationProcessor.py 1.67 KB
Newer Older
赵小蒙's avatar
赵小蒙 committed
1
2
import unittest

赵小蒙's avatar
赵小蒙 committed
3
from pdf_tools.post_proc.detect_para import BlockContinuationProcessor
赵小蒙's avatar
赵小蒙 committed
4
5
6
7
8
9

# from ... pdf2text_recogPara import BlockContinuationProcessor # another way to import

"""
Execute the following command to run the test under directory code-clean:

赵小蒙's avatar
赵小蒙 committed
10
    python -m tests.test_para.test_pdf2text_recogPara_ClassName
赵小蒙's avatar
赵小蒙 committed
11
12
13
    
    or
    
赵小蒙's avatar
赵小蒙 committed
14
    pytest -v -s app/pdf_toolbox/tests/test_para/test_pdf2text_recogPara_BlockContinuationProcessor.py
赵小蒙's avatar
赵小蒙 committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    
"""


class TestIsAlphabetChar(unittest.TestCase):
    def setUp(self):
        self.obj = BlockContinuationProcessor()

    def test_is_alphabet_char(self):
        char = "A"
        result = self.obj._is_alphabet_char(char)
        self.assertTrue(result)

    def test_is_not_alphabet_char(self):
        char = "1"
        result = self.obj._is_alphabet_char(char)
        self.assertFalse(result)


class TestIsChineseChar(unittest.TestCase):
    def setUp(self):
        self.obj = BlockContinuationProcessor()

    def test_is_chinese_char(self):
        char = "中"
        result = self.obj._is_chinese_char(char)
        self.assertTrue(result)

    def test_is_not_chinese_char(self):
        char = "A"
        result = self.obj._is_chinese_char(char)
        self.assertFalse(result)


class TestIsOtherLetterChar(unittest.TestCase):
    def setUp(self):
        self.obj = BlockContinuationProcessor()

    def test_is_other_letter_char(self):
        char = "Ä"
        result = self.obj._is_other_letter_char(char)
        self.assertTrue(result)

    def test_is_not_other_letter_char(self):
        char = "A"
        result = self.obj._is_other_letter_char(char)
        self.assertFalse(result)


if __name__ == "__main__":
    unittest.main()