Skip to content

Commit 73bc9a1

Browse files
Remove left-over support for classic implementation, mostly in tests/.
1 parent 4769a26 commit 73bc9a1

13 files changed

Lines changed: 78 additions & 162 deletions

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def build():
631631
)
632632
log( f'build(): mupdf_build_dir={mupdf_build_dir!r}')
633633

634-
# Build rebased `extra` module.
634+
# Build `extra` module.
635635
#
636636
if 'p' in PYMUPDF_SETUP_FLAVOUR:
637637
path_so_leaf = _build_extension(
@@ -1094,8 +1094,7 @@ def _build_extension( mupdf_local, mupdf_build_dir, build_type, g_py_limited_api
10941094
f'{mupdf_local}/include',
10951095
)
10961096

1097-
# Build rebased extension module.
1098-
log('Building PyMuPDF rebased.')
1097+
log('Building PyMuPDF extension.')
10991098
compile_extra_cpp = ''
11001099
if darwin:
11011100
# Avoids `error: cannot pass object of non-POD type

src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25897,6 +25897,6 @@ def deprecated_function( *args, **kwargs):
2589725897

2589825898
__version__ = VersionBind
2589925899
__doc__ = (
25900-
f'PyMuPDF {VersionBind}: Python bindings for the MuPDF {VersionFitz} library (rebased implementation).\n'
25900+
f'PyMuPDF {VersionBind}: Python bindings for the MuPDF {VersionFitz} library.\n'
2590125901
f'Python {sys.version_info[0]}.{sys.version_info[1]} running on {sys.platform} ({64 if sys.maxsize > 2**32 else 32}-bit).\n'
2590225902
)

tests/test_2548.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,20 @@ def test_2548():
1818
_ = page.get_text()
1919
except Exception as ee:
2020
print(f'test_2548: {ee=}')
21-
if hasattr(pymupdf, 'mupdf'):
22-
# Rebased.
23-
expected = "RuntimeError('code=2: cycle in structure tree')"
24-
else:
25-
# Classic.
26-
expected = "RuntimeError('cycle in structure tree')"
21+
expected = "RuntimeError('code=2: cycle in structure tree')"
2722
assert repr(ee) == expected, f'Expected {expected=} but got {repr(ee)=}.'
2823
e = True
2924
wt = pymupdf.TOOLS.mupdf_warnings()
3025
print(f'test_2548(): {wt=}')
3126

3227
# This checks that PyMuPDF 1.23.7 fixes this bug, and also that earlier
3328
# versions with updated MuPDF also fix the bug.
34-
rebased = hasattr(pymupdf, 'mupdf')
3529
if pymupdf.mupdf_version_tuple >= (1, 27, 1):
3630
expected = ''
3731
elif pymupdf.mupdf_version_tuple >= (1, 27):
3832
expected = 'format error: No common ancestor in structure tree\nstructure tree broken, assume tree is missing'
3933
expected = '\n'.join([expected] * 5)
4034
else:
4135
expected = 'format error: cycle in structure tree\nstructure tree broken, assume tree is missing'
42-
if rebased:
43-
assert wt == expected, f'expected:\n {expected!r}\nwt:\n {wt!r}\n'
36+
assert wt == expected, f'expected:\n {expected!r}\nwt:\n {wt!r}\n'
4437
assert not e

tests/test_2904.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ def test_2904():
2727
print(f'{pymupdf.mupdf_version_tuple=}: {page_id=} {i=} {e=} {img=}:')
2828
if page_id == 5 and i==3:
2929
assert e
30-
if hasattr(pymupdf, 'mupdf'):
31-
# rebased.
32-
assert str(e) == 'code=8: Failed to read JPX header'
33-
else:
34-
# classic
35-
assert str(e) == 'Failed to read JPX header'
30+
assert str(e) == 'code=8: Failed to read JPX header'
3631
else:
3732
assert not e
3833

tests/test_codespell.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@
1010

1111
def test_codespell():
1212
'''
13-
Check rebased Python code with codespell.
13+
Check Python code with codespell.
1414
'''
1515
if os.environ.get('PYODIDE_ROOT'):
1616
print('test_codespell(): not running on Pyodide - cannot run child processes.')
1717
return
1818

19-
if not hasattr(pymupdf, 'mupdf'):
20-
print('Not running codespell with classic implementation.')
21-
return
22-
2319
if platform.system() == 'Windows':
2420
# Git commands seem to fail on Github Windows runners.
2521
print(f'test_codespell(): Not running on Windows')

tests/test_flake8.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77

88
def test_flake8():
99
'''
10-
Check rebased Python code with flake8.
10+
Check Python code with flake8.
1111
'''
1212
if os.environ.get('PYODIDE_ROOT'):
1313
print('test_flake8(): not running on Pyodide - cannot run child processes.')
1414
return
1515

16-
if not hasattr(pymupdf, 'mupdf'):
17-
print(f'Not running flake8 with classic implementation.')
18-
return
1916
ignores = (
2017
'E123', # closing bracket does not match indentation of opening bracket's line
2118
'E124', # closing bracket does not match visual indentation

tests/test_font.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ def test_font1():
3434
# Also check we can get font's bbox.
3535
bbox1 = font.bbox
3636
print(f'{bbox1=}')
37-
if hasattr(pymupdf, 'mupdf'):
38-
bbox2 = font.this.fz_font_bbox()
39-
assert bbox2 == bbox1
37+
bbox2 = font.this.fz_font_bbox()
38+
assert bbox2 == bbox1
4039

4140

4241
def test_font2():
@@ -105,9 +104,6 @@ def test_fontarchive():
105104
]
106105

107106
def test_load_system_font():
108-
if not hasattr(pymupdf, 'mupdf'):
109-
print(f'test_load_system_font(): Not running on classic.')
110-
return
111107
trace = list()
112108
def font_f(name, bold, italic, needs_exact_metrics):
113109
trace.append((name, bold, italic, needs_exact_metrics))
@@ -130,9 +126,6 @@ def f_fallback(script, language, serif, bold, italic):
130126

131127

132128
def test_mupdf_subset_fonts2():
133-
if not hasattr(pymupdf, 'mupdf'):
134-
print('Not running on rebased.')
135-
return
136129
path = os.path.abspath(f'{__file__}/../../tests/resources/2.pdf')
137130
with pymupdf.open(path) as doc:
138131
n = len(doc)

tests/test_general.py

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,11 @@ def test_wrapcontents():
8686
page.set_contents(xref)
8787
assert len(page.get_contents()) == 1
8888
page.clean_contents()
89-
rebased = hasattr(pymupdf, 'mupdf')
90-
if rebased:
91-
wt = pymupdf.TOOLS.mupdf_warnings()
92-
if (1, 26, 0) <= pymupdf.mupdf_version_tuple < (1, 27):
93-
assert wt == 'bogus font ascent/descent values (0 / 0)\nPDF stream Length incorrect'
94-
else:
95-
assert wt == 'PDF stream Length incorrect'
89+
wt = pymupdf.TOOLS.mupdf_warnings()
90+
if (1, 26, 0) <= pymupdf.mupdf_version_tuple < (1, 27):
91+
assert wt == 'bogus font ascent/descent values (0 / 0)\nPDF stream Length incorrect'
92+
else:
93+
assert wt == 'PDF stream Length incorrect'
9694

9795

9896
def test_page_clean_contents():
@@ -300,8 +298,8 @@ def test_2533():
300298
Search for a unique char on page and confirm that page.get_texttrace()
301299
returns the same bbox as the search method.
302300
"""
303-
if hasattr(pymupdf, 'mupdf') and not pymupdf.g_use_extra:
304-
print('Not running test_2533() because rebased with use_extra=0 known to fail')
301+
if not pymupdf.g_use_extra:
302+
print('Not running test_2533() because use_extra=0 known to fail')
305303
return
306304
pymupdf.TOOLS.set_small_glyph_heights(True)
307305
try:
@@ -412,18 +410,16 @@ def test_2108():
412410
def test_2238():
413411
filepath = f'{scriptdir}/resources/test2238.pdf'
414412
doc = pymupdf.open(filepath)
415-
rebased = hasattr(pymupdf, 'mupdf')
416-
if rebased:
417-
wt = pymupdf.TOOLS.mupdf_warnings()
418-
wt_expected = ''
419-
if pymupdf.mupdf_version_tuple >= (1, 26):
420-
wt_expected += 'garbage bytes before version marker\n'
421-
wt_expected += 'syntax error: expected \'obj\' keyword (6 0 ?)\n'
422-
else:
423-
wt_expected += 'format error: cannot recognize version marker\n'
424-
wt_expected += 'trying to repair broken xref\n'
425-
wt_expected += 'repairing PDF document'
426-
assert wt == wt_expected, f'{wt=}'
413+
wt = pymupdf.TOOLS.mupdf_warnings()
414+
wt_expected = ''
415+
if pymupdf.mupdf_version_tuple >= (1, 26):
416+
wt_expected += 'garbage bytes before version marker\n'
417+
wt_expected += 'syntax error: expected \'obj\' keyword (6 0 ?)\n'
418+
else:
419+
wt_expected += 'format error: cannot recognize version marker\n'
420+
wt_expected += 'trying to repair broken xref\n'
421+
wt_expected += 'repairing PDF document'
422+
assert wt == wt_expected, f'{wt=}'
427423
first_page = doc.load_page(0).get_text('text', clip=pymupdf.INFINITE_RECT())
428424
last_page = doc.load_page(-1).get_text('text', clip=pymupdf.INFINITE_RECT())
429425

@@ -619,7 +615,6 @@ def test_2596():
619615
page = doc.reload_page(page)
620616
pix1 = page.get_pixmap()
621617
assert pix1.samples == pix0.samples
622-
rebased = hasattr(pymupdf, 'mupdf')
623618
if pymupdf.mupdf_version_tuple < (1, 26, 6):
624619
wt = pymupdf.TOOLS.mupdf_warnings()
625620
assert wt == 'too many indirections (possible indirection cycle involving 24 0 R)'
@@ -747,14 +742,12 @@ def assert_rects_approx_eq(a, b):
747742
print(f'test_2710(): {pymupdf.mupdf_version_tuple=}')
748743
# 2023-11-05: Currently broken in mupdf master.
749744
print(f'test_2710(): Not Checking page.rect and rect.')
750-
rebased = hasattr(pymupdf, 'mupdf')
751-
if rebased:
752-
wt = pymupdf.TOOLS.mupdf_warnings()
753-
assert wt == (
754-
"syntax error: cannot find ExtGState resource 'GS7'\n"
755-
"syntax error: cannot find ExtGState resource 'GS8'\n"
756-
"encountered syntax errors; page may not be correct"
757-
)
745+
wt = pymupdf.TOOLS.mupdf_warnings()
746+
assert wt == (
747+
"syntax error: cannot find ExtGState resource 'GS7'\n"
748+
"syntax error: cannot find ExtGState resource 'GS8'\n"
749+
"encountered syntax errors; page may not be correct"
750+
)
758751

759752

760753
def test_2736():
@@ -930,8 +923,6 @@ def test_3081():
930923
path1 = os.path.abspath(f'{__file__}/../../tests/resources/1.pdf')
931924
path2 = os.path.abspath(f'{__file__}/../../tests/test_3081-2.pdf')
932925

933-
rebased = hasattr(pymupdf, 'mupdf')
934-
935926
import shutil
936927
import sys
937928
import traceback
@@ -953,9 +944,8 @@ def next_fd():
953944
page = document[0]
954945
fd2 = next_fd()
955946
document.close()
956-
if rebased:
957-
assert document.this is None
958-
assert page.this is None
947+
assert document.this is None
948+
assert page.this is None
959949
try:
960950
document.page_count()
961951
except Exception as e:
@@ -970,10 +960,7 @@ def next_fd():
970960
except Exception as e:
971961
print(f'Received expected exception: {e}')
972962
#traceback.print_exc(file=sys.stdout)
973-
if rebased:
974-
assert str(e) == 'page is None'
975-
else:
976-
assert str(e) == 'orphaned object: parent is None'
963+
assert str(e) == 'page is None'
977964
else:
978965
assert 0, 'Did not receive expected exception.'
979966
page = None
@@ -996,17 +983,11 @@ def test_3112_set_xml_metadata():
996983
document.set_xml_metadata('hello world')
997984

998985
def test_archive_3126():
999-
if not hasattr(pymupdf, 'mupdf'):
1000-
print(f'Not running because known to fail with classic.')
1001-
return
1002986
p = os.path.abspath(f'{__file__}/../../tests/resources')
1003987
p = pathlib.Path(p)
1004988
archive = pymupdf.Archive(p)
1005989

1006990
def test_3140():
1007-
if not hasattr(pymupdf, 'mupdf'):
1008-
print(f'Not running test_3140 on classic, because Page.insert_htmlbox() not available.')
1009-
return
1010991
css2 = ''
1011992
path = os.path.abspath(f'{__file__}/../../tests/resources/2.pdf')
1012993
oldfile = os.path.abspath(f'{__file__}/../../tests/test_3140_old.pdf')
@@ -1043,9 +1024,6 @@ def test_cli():
10431024
print('test_cli(): not running on Pyodide - cannot run child processes.')
10441025
return
10451026

1046-
if not hasattr(pymupdf, 'mupdf'):
1047-
print('test_cli(): Not running on classic because of fitz_old.')
1048-
return
10491027
import subprocess
10501028
subprocess.run(f'pymupdf -h', shell=1, check=1)
10511029

@@ -1108,9 +1086,6 @@ def test_cli_out():
11081086
print('test_cli_out(): not running on Pyodide - cannot run child processes.')
11091087
return
11101088

1111-
if not hasattr(pymupdf, 'mupdf'):
1112-
print('test_cli(): Not running on classic because of fitz_old.')
1113-
return
11141089
import platform
11151090
import re
11161091
import subprocess
@@ -1395,10 +1370,6 @@ def relpath(path, start=None):
13951370

13961371
def test_open():
13971372

1398-
if not hasattr(pymupdf, 'mupdf'):
1399-
print('test_open(): not running on classic.')
1400-
return
1401-
14021373
import re
14031374
import textwrap
14041375
import traceback
@@ -1650,9 +1621,6 @@ def show(r, name):
16501621

16511622

16521623
def test_533():
1653-
if not hasattr(pymupdf, 'mupdf'):
1654-
print('test_533(): Not running on classic.')
1655-
return
16561624
path = os.path.abspath(f'{__file__}/../../tests/resources/2.pdf')
16571625
doc = pymupdf.open(path)
16581626
print()

tests/test_objectstreams.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ def test_objectstream1():
66
This option compresses PDF object definitions into a special object type
77
"ObjStm". We test its presence by searching for that /Type.
88
"""
9-
if not hasattr(pymupdf, "mupdf"):
10-
# only implemented for rebased
11-
return
12-
139
# make some arbitrary page with content
1410
text = "Hello, World! Hallo, Welt!"
1511
doc = pymupdf.open()
@@ -32,10 +28,6 @@ def test_objectstream2():
3228
This option compresses PDF object definitions into a special object type
3329
"ObjStm". We test its presence by searching for that /Type.
3430
"""
35-
if not hasattr(pymupdf, "mupdf"):
36-
# only implemented for rebased
37-
return
38-
3931
# make some arbitrary page with content
4032
text = "Hello, World! Hallo, Welt!"
4133
doc = pymupdf.open()
@@ -58,9 +50,6 @@ def test_objectstream3():
5850
"""Test ez_save().
5951
Should automatically use object streams
6052
"""
61-
if not hasattr(pymupdf, "mupdf"):
62-
# only implemented for rebased
63-
return
6453
import io
6554

6655
fp = io.BytesIO()

tests/test_pixmap.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def product(x, y):
184184
for xx in x:
185185
yield (xx, yy)
186186
n = 0
187-
# We use a small subset of the image because non-optimised rebase gets
187+
# We use a small subset of the image because non-optimised build gets
188188
# very slow.
189189
for pos in product(range(100), range(100)):
190190
if sum(pix.pixel(pos[0], pos[1])) >= 600:
@@ -247,15 +247,13 @@ def test_3072():
247247
pix = page_49.get_pixmap(clip=rect, matrix=zoom)
248248
image_save_path = f'{out}/2.jpg'
249249
pix.save(image_save_path, jpg_quality=95)
250-
rebase = hasattr(pymupdf, 'mupdf')
251-
if rebase:
252-
wt = pymupdf.TOOLS.mupdf_warnings()
253-
assert wt == (
254-
"syntax error: cannot find ExtGState resource 'BlendMode0'\n"
255-
"encountered syntax errors; page may not be correct\n"
256-
"syntax error: cannot find ExtGState resource 'BlendMode0'\n"
257-
"encountered syntax errors; page may not be correct"
258-
)
250+
wt = pymupdf.TOOLS.mupdf_warnings()
251+
assert wt == (
252+
"syntax error: cannot find ExtGState resource 'BlendMode0'\n"
253+
"encountered syntax errors; page may not be correct\n"
254+
"syntax error: cannot find ExtGState resource 'BlendMode0'\n"
255+
"encountered syntax errors; page may not be correct"
256+
)
259257

260258
def test_3134():
261259
doc = pymupdf.Document()

0 commit comments

Comments
 (0)