From 19ba3ae011ab0323f4833a005e4c512d94d6c5b1 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 3 Sep 2019 17:38:54 -0700 Subject: [PATCH] Allow test_german to xfail if deu language is not installed --- tests/spoof/tesseract_cache.py | 2 ++ tests/test_main.py | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/spoof/tesseract_cache.py b/tests/spoof/tesseract_cache.py index db06aa8e..528e5a1e 100755 --- a/tests/spoof/tesseract_cache.py +++ b/tests/spoof/tesseract_cache.py @@ -100,6 +100,8 @@ def main(): # Convert non-standard but supported -psm to --psm sys.argv = ['--psm' if arg == '-psm' else arg for arg in sys.argv] + if '_OCRMYPDF_TEST_INFILE' not in os.environ: + real_tesseract() # test not properly set up source = os.environ['_OCRMYPDF_TEST_INFILE'] # required args = parser.parse_args() diff --git a/tests/test_main.py b/tests/test_main.py index 11e02993..e87e5163 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -349,10 +349,9 @@ def test_german(spoof_tesseract_cache, resources, outdir): sidecar, env=spoof_tesseract_cache, ) - print(os.environ) - assert ( - p.returncode == ExitCode.ok - ), "This test may fail if Tesseract language packs are missing" + 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" def test_klingon(resources, outpdf):