"docs/vscode:/vscode.git/clone" did not exist on "b9a54e0968970a5f8021650136175660ea7ee565"
test_pdf2text_recogPara_BlockContinuationProcessor.py 1.66 KB
Newer Older
赵小蒙's avatar
赵小蒙 committed
1
2
import unittest

赵小蒙's avatar
赵小蒙 committed
3
from post_proc.detect_para import BlockContinuationProcessor
赵小蒙's avatar
赵小蒙 committed
4
5
6
7
8
9
10
11
12
13
14
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

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

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

    python -m test.test_para.test_pdf2text_recogPara_ClassName
    
    or
    
    pytest -v -s app/pdf_toolbox/test/test_para/test_pdf2text_recogPara_BlockContinuationProcessor.py
    
"""


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()