Skip to content

Commit 868cf48

Browse files
tests/test_tesseract.py:test_tesseract(): minor change for Pyodide.
1 parent 148fcc3 commit 868cf48

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/test_tesseract.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ def test_tesseract():
1515
But if TESSDATA_PREFIX is set in the environment, we assert that
1616
FzPage.get_textpage_ocr() succeeds.
1717
'''
18-
if os.environ.get('PYODIDE_ROOT'):
19-
print('test_tesseract(): not running on Pyodide - cannot run child processes.')
20-
return
21-
2218
path = os.path.abspath( f'{__file__}/../resources/2.pdf')
2319
doc = pymupdf.open( path)
2420
page = doc[5]
@@ -28,14 +24,18 @@ def test_tesseract():
2824
tail = 'OCR initialisation failed'
2925
else:
3026
tail = 'Tesseract language initialisation failed'
31-
e_expected = f'code=3: {tail}'
32-
if platform.system() == 'OpenBSD':
33-
# 2023-12-12: For some reason the SWIG catch code only catches
34-
# the exception as FzErrorBase.
35-
e_expected_type = pymupdf.mupdf.FzErrorBase
36-
print(f'OpenBSD workaround - expecting FzErrorBase, not FzErrorLibrary.')
27+
if os.environ.get('PYODIDE_ROOT'):
28+
e_expected = 'code=6: No OCR support in this build'
29+
e_expected_type = pymupdf.mupdf.FzErrorUnsupported
3730
else:
38-
e_expected_type = pymupdf.mupdf.FzErrorLibrary
31+
e_expected = f'code=3: {tail}'
32+
if platform.system() == 'OpenBSD':
33+
# 2023-12-12: For some reason the SWIG catch code only catches
34+
# the exception as FzErrorBase.
35+
e_expected_type = pymupdf.mupdf.FzErrorBase
36+
print(f'OpenBSD workaround - expecting FzErrorBase, not FzErrorLibrary.')
37+
else:
38+
e_expected_type = pymupdf.mupdf.FzErrorLibrary
3939
else:
4040
# classic.
4141
e_expected = 'OCR initialisation failed'

0 commit comments

Comments
 (0)