Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_proper_oserror_exception_handling(test_file, test_path):
""""Test for bubbling up OSError exceptions."""
import pytesseract
pytesseract.pytesseract.tesseract_cmd = test_path
with pytest.raises(
TesseractNotFoundError if IS_PYTHON_2 and test_path else OSError
):
pytesseract.pytesseract.image_to_string(test_file)
pytesseract.pytesseract.tesseract_cmd = 'tesseract' # restore the def value
def test_wrong_tesseract_cmd(test_file, test_path):
"""Test wrong or missing tesseract command."""
import pytesseract
pytesseract.pytesseract.tesseract_cmd = test_path
with pytest.raises(TesseractNotFoundError):
pytesseract.pytesseract.image_to_string(test_file)
pytesseract.pytesseract.tesseract_cmd = 'tesseract' # restore the def value