Skip to content

Commit

Permalink
tests/test_general.py:test_open(): workaround swig bug on openbsd.
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-smith-artifex-com committed Mar 19, 2024
1 parent 517ecfa commit f039ad4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit f039ad4

Please sign in to comment.