OCRmyPDF/tests/test_api.py

28 lines
627 B
Python
Raw Normal View History

2022-07-28 01:06:46 -07:00
# SPDX-FileCopyrightText: 2022 James R. Barlow
# SPDX-License-Identifier: MPL-2.0
2019-12-30 17:51:09 -08:00
2022-07-23 00:39:24 -07:00
from __future__ import annotations
2019-12-30 17:51:09 -08:00
import logging
from io import BytesIO, StringIO
2019-12-30 17:51:09 -08:00
import pytest
import ocrmypdf
def test_language_list():
2020-04-15 02:26:20 -07:00
with pytest.raises(
(ocrmypdf.exceptions.InputFileError, ocrmypdf.exceptions.MissingDependencyError)
):
ocrmypdf.ocr('doesnotexist.pdf', '_.pdf', language=['eng', 'deu'])
def test_stream_api(resources):
in_ = (resources / 'graph.pdf').open('rb')
out = BytesIO()
ocrmypdf.ocr(in_, out, tesseract_timeout=0.0)
out.seek(0)
assert b'%PDF' in out.read(1024)