test_formula_recognition.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import pytest
  2. from paddleocr import FormulaRecognition
  3. from ..testing_utils import (
  4. TEST_DATA_DIR,
  5. check_simple_inference_result,
  6. check_wrapper_simple_inference_param_forwarding,
  7. )
  8. @pytest.fixture(scope="module")
  9. def formula_recognition_predictor():
  10. return FormulaRecognition()
  11. @pytest.mark.parametrize(
  12. "image_path",
  13. [
  14. TEST_DATA_DIR / "formula.png",
  15. ],
  16. )
  17. def test_predict(formula_recognition_predictor, image_path):
  18. result = formula_recognition_predictor.predict(str(image_path))
  19. check_simple_inference_result(result)
  20. assert result[0].keys() == {
  21. "input_path",
  22. "page_index",
  23. "input_img",
  24. "rec_formula",
  25. }
  26. @pytest.mark.parametrize(
  27. "params",
  28. [
  29. {},
  30. ],
  31. )
  32. def test_predict_params(
  33. monkeypatch,
  34. formula_recognition_predictor,
  35. params,
  36. ):
  37. check_wrapper_simple_inference_param_forwarding(
  38. monkeypatch,
  39. formula_recognition_predictor,
  40. "paddlex_predictor",
  41. "dummy_path",
  42. params,
  43. )