Ejemplo n.º 1
0
def test_no_languages(tmp_path):
    env = os.environ.copy()
    (tmp_path / 'tessdata').mkdir()
    env['TESSDATA_PREFIX'] = fspath(tmp_path)

    with pytest.raises(MissingDependencyError):
        tesseract.languages(tesseract_env=env)
Ejemplo n.º 2
0
def test_no_languages(ensure_tess4, tmpdir):
    env = ensure_tess4
    (tmpdir / 'tessdata').mkdir()
    env['TESSDATA_PREFIX'] = fspath(tmpdir)

    with modified_os_environ(env):
        with pytest.raises(MissingDependencyError):
            tesseract.languages.cache_clear()
            tesseract.languages()
Ejemplo n.º 3
0
def test_no_languages(ensure_tess4, tmpdir):
    env = ensure_tess4
    (tmpdir / 'tessdata').mkdir()
    env['TESSDATA_PREFIX'] = fspath(tmpdir)

    with modified_os_environ(env):
        with pytest.raises(MissingDependencyError):
            tesseract.languages.cache_clear()
            tesseract.languages()
Ejemplo n.º 4
0
def test_german(spoof_tesseract_cache, resources, outdir):
    # Produce a sidecar too - implicit test that system locale is set up
    # properly. It is fine that we are testing -l deu on a French file because
    # we are exercising the functionality not going for accuracy.
    sidecar = outdir / 'francais.txt'
    p, out, err = run_ocrmypdf(
        resources / 'francais.pdf',
        outdir / 'francais.pdf',
        '-l',
        'deu',  # more commonly installed
        '--sidecar',
        sidecar,
        env=spoof_tesseract_cache,
    )
    if 'deu' not in tesseract.languages():
        pytest.xfail(reason="tesseract-deu language pack not installed")
    assert p.returncode == ExitCode.ok, "Requires tesseract deu language pack"
Ejemplo n.º 5
0
def test_german(spoof_tesseract_cache, resources, outdir):
    # Produce a sidecar too - implicit test that system locale is set up
    # properly. It is fine that we are testing -l deu on a French file because
    # we are exercising the functionality not going for accuracy.
    sidecar = outdir / 'francais.txt'
    try:
        check_ocrmypdf(
            resources / 'francais.pdf',
            outdir / 'francais.pdf',
            '-l',
            'deu',  # more commonly installed
            '--sidecar',
            sidecar,
            env=spoof_tesseract_cache,
        )
    except MissingDependencyError:
        if 'deu' not in tesseract.languages():
            pytest.xfail(reason="tesseract-deu language pack not installed")
        raise