From f039ad400807bb22befb408abb71b7d0cb485086 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Mon, 18 Mar 2024 20:38:02 +0000 Subject: [PATCH] tests/test_general.py:test_open(): workaround swig bug on openbsd. --- tests/test_general.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_general.py b/tests/test_general.py index 3237ead5a..1f2206888 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -1108,19 +1108,23 @@ def check(filename=None, stream=None, filetype=None, exception=None): path = f'{resources}/1.pdf' filetype = 'xps' etype = fitz.FileDataError + # 2023-12-12: On OpenBSD, for some reason the SWIG catch code only catches + # the exception as FzErrorBase. + etype2 = 'FzErrorBase' if platform.system() == 'OpenBSD' else 'FzErrorFormat' eregex = ( # With a sysinstall with separate MuPDF install, we get # `mupdf.FzErrorFormat` instead of `fitz.mupdf.FzErrorFormat`. So # we just search for the former. - re.escape(f'mupdf.FzErrorFormat: code=7: cannot recognize zip archive'), + re.escape(f'mupdf.{etype2}: code=7: cannot recognize zip archive'), re.escape(f'fitz.FileDataError: Failed to open file {path!r} as type {filetype!r}.'), ) check(path, filetype=filetype, exception=(etype, eregex)) path = f'{resources}/chinese-tables.pickle' etype = fitz.FileDataError + etype2 = 'FzErrorBase' if platform.system() == 'OpenBSD' else 'FzErrorUnsupported' etext = ( - re.escape(f'mupdf.FzErrorUnsupported: code=6: cannot find document handler for file: {path}'), + re.escape(f'mupdf.{etype2}: code=6: cannot find document handler for file: {path}'), re.escape(f'fitz.FileDataError: Failed to open file {path!r}.'), ) check(path, exception=(etype, etext))