示例#1
0
def test_find(image, text):
    matches = ocr.find(IMAGES / image, text)
    assert len(matches) == 1

    match = matches[0]
    assert match["text"] == text
    assert match["confidence"] == 100
示例#2
0
        def finder(image: Image.Image) -> List[Region]:
            matches = ocr.find(
                image=image,
                text=locator.text,
                confidence=confidence,
            )

            return [match["region"] for match in matches]
示例#3
0
def test_find_when_no_tesseract(monkeypatch):
    monkeypatch.setattr("pytesseract.pytesseract.tesseract_cmd",
                        "totallynotatesseract.exe")

    expected_text = ("tesseract is not installed or not in PATH, "
                     "see library documentation for installation instructions")
    with pytest.raises(EnvironmentError) as err:
        _ = ocr.find(GNUCASH_MAIN_WINDOW, "fail")

    assert str(err.value) == expected_text
示例#4
0
def test_find_no_text():
    with pytest.raises(ValueError) as err:
        _ = ocr.find(GNUCASH_MAIN_WINDOW, "")

    assert str(err.value) == "Empty search string"