From 33cdabaf654bfb872354bc0c69ff5cf731267e43 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 26 May 2022 13:52:22 -0700 Subject: [PATCH] tests: account for test that expected pngquant for windows --- tests/test_pdfa.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/test_pdfa.py b/tests/test_pdfa.py index 75b22a57..31edb5dd 100644 --- a/tests/test_pdfa.py +++ b/tests/test_pdfa.py @@ -4,23 +4,31 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import os + import pikepdf import pytest +from ocrmypdf.exceptions import MissingDependencyError + from .conftest import check_ocrmypdf @pytest.mark.parametrize('optimize', (0, 3)) @pytest.mark.parametrize('pdfa_level', (1, 2, 3)) def test_pdfa(resources, outpdf, optimize, pdfa_level): - check_ocrmypdf( - resources / 'francais.pdf', - outpdf, - '--plugin', - 'tests/plugins/tesseract_noop.py', - f'--output-type=pdfa-{pdfa_level}', - f'--optimize={optimize}', - ) + try: + check_ocrmypdf( + resources / 'francais.pdf', + outpdf, + '--plugin', + 'tests/plugins/tesseract_noop.py', + f'--output-type=pdfa-{pdfa_level}', + f'--optimize={optimize}', + ) + except MissingDependencyError as e: + if 'pngquant' in str(e) and optimize in (2, 3) and os.name == 'nt': + pytest.xfail("pngquant currently not available on Windows") if pdfa_level in (2, 3): # PDF/A-2 allows ObjStm assert b'/ObjStm' in outpdf.read_bytes()