Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,9 +927,12 @@ def cibuildwheel(
# will notice that the wheel we built above supports all versions of
# Python, so will not actually do any builds here.
#
env_extra['CIBW_BUILD'] = CIBW_BUILD
run(f'cd {pymupdf_dir} && cibuildwheel{cibw_pyodide_args}', env_extra=env_extra)
run(f'ls -ld {pymupdf_dir}/wheelhouse/*')
# We only do this if there are more than one Python versions. This still
# duplicates the testing of the first python version.
if len(CIBW_BUILD.split()) > 1:
env_extra['CIBW_BUILD'] = CIBW_BUILD
run(f'cd {pymupdf_dir} && cibuildwheel{cibw_pyodide_args}', env_extra=env_extra)
run(f'ls -ld {pymupdf_dir}/wheelhouse/*')


def cibw_do_test_project(env_extra, CIBW_BUILD, cibw_pyodide, cibw_pyodide_args):
Expand Down
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,25 @@ def get_members(a):
# Allow post-test checking that pymupdf._globals has not changed.
_globals_pre = get_members(pymupdf._globals)

testsfailed_before = request.session.testsfailed

# Run the test.
rep = yield

sys.stdout.flush()

# This seems the only way for us to tell that a test has failed. In
# particular, <rep> is always None. We're implicitly relying on tests not
# being run in parallel.
#
failed = request.session.testsfailed - testsfailed_before
assert failed in (0, 1)

if failed:
# Do not check post-test conditions if the test as failed. This avoids
# additional confusing `ERROR` status for failed tests.
return

# Test has run; check it did not create any MuPDF warnings etc.
wt = pymupdf.TOOLS.mupdf_warnings()
if not hasattr(pymupdf, 'mupdf'):
Expand Down
22 changes: 11 additions & 11 deletions tests/test_tesseract.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def test_tesseract():
But if TESSDATA_PREFIX is set in the environment, we assert that
FzPage.get_textpage_ocr() succeeds.
'''
if os.environ.get('PYODIDE_ROOT'):
print('test_tesseract(): not running on Pyodide - cannot run child processes.')
return

path = os.path.abspath( f'{__file__}/../resources/2.pdf')
doc = pymupdf.open( path)
page = doc[5]
Expand All @@ -28,14 +24,18 @@ def test_tesseract():
tail = 'OCR initialisation failed'
else:
tail = 'Tesseract language initialisation failed'
e_expected = f'code=3: {tail}'
if platform.system() == 'OpenBSD':
# 2023-12-12: For some reason the SWIG catch code only catches
# the exception as FzErrorBase.
e_expected_type = pymupdf.mupdf.FzErrorBase
print(f'OpenBSD workaround - expecting FzErrorBase, not FzErrorLibrary.')
if os.environ.get('PYODIDE_ROOT'):
e_expected = 'code=6: No OCR support in this build'
e_expected_type = pymupdf.mupdf.FzErrorUnsupported
else:
e_expected_type = pymupdf.mupdf.FzErrorLibrary
e_expected = f'code=3: {tail}'
if platform.system() == 'OpenBSD':
# 2023-12-12: For some reason the SWIG catch code only catches
# the exception as FzErrorBase.
e_expected_type = pymupdf.mupdf.FzErrorBase
print(f'OpenBSD workaround - expecting FzErrorBase, not FzErrorLibrary.')
else:
e_expected_type = pymupdf.mupdf.FzErrorLibrary
else:
# classic.
e_expected = 'OCR initialisation failed'
Expand Down