forked from PaddlePaddle/PaddleOCR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_ppstructure.py
53 lines (39 loc) · 1.33 KB
/
test_ppstructure.py
1
2
3
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
# -*- encoding: utf-8 -*-
from pathlib import Path
from typing import Any
import pytest
from paddleocr import PPStructure
cur_dir = Path(__file__).resolve().parent
test_file_dir = cur_dir / "test_files"
IMAGE_PATHS_STRUCTURE = [
str(test_file_dir / "ppstructure" / "layout.jpg"),
str(test_file_dir / "ppstructure" / "1.png"),
]
@pytest.fixture(params=["en", "ch"])
def structure_engine(request: Any) -> PPStructure:
"""
Initialize PPStructure engine with different languages.
Args:
request: pytest fixture request object.
Returns:
An instance of PPStructure.
"""
return PPStructure(lang=request.param)
def test_structure_initialization(structure_engine: PPStructure) -> None:
"""
Test PPStructure initialization.
Args:
structure_engine: An instance of PPStructure.
"""
assert structure_engine is not None
@pytest.mark.parametrize("image_path", IMAGE_PATHS_STRUCTURE)
def test_structure_function(structure_engine: PPStructure, image_path: str) -> None:
"""
Test PPStructure structure analysis functionality with different images.
Args:
structure_engine: An instance of PPStructure.
image_path: Path to the image to be processed.
"""
result = structure_engine(image_path)
assert result is not None
assert isinstance(result, list)