diff --git a/changes.txt b/changes.txt index 47cab42ee..0abc9b5ba 100644 --- a/changes.txt +++ b/changes.txt @@ -33,6 +33,7 @@ Change Log * **Fixed** `4520 `_: show_pdf_page does not like empty pages created by new_page * **Fixed** `4524 `_: fitz.get_text ignores 'pages' kwarg * **Fixed** `4412 `_: Regression? Spurious error? in insert_pdf in v1.25.4 + * **Fixed** `4496 `_: pymupdf4llm with pymupdfpro * Other: diff --git a/scripts/test.py b/scripts/test.py index a6095f40e..340d10829 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -107,13 +107,16 @@ -h Show help. - -i + -I Set PyMuPDF implementations to test. must contain only these individual characters: 'r' - rebased. 'R' - rebased without optimisations. Default is 'r'. Also see `PyMuPDF:tests/run_compound.py`. + -i + Set version installed by the 'install' command. + -k Specify which test(s) to run; passed straight through to pytest's `-k`. For example `-k test_3354`. @@ -298,6 +301,7 @@ def main(argv): commands = list() env_extra = dict() implementations = 'r' + install_version = None mupdf_sync = None os_names = list() system_packages = False @@ -393,6 +397,9 @@ def main(argv): show_help = True elif arg == '-i': + install_version = next(args) + + elif arg == '-I': implementations = next(args) elif arg == '-k': @@ -459,16 +466,12 @@ def main(argv): venv = int(next(args)) assert venv in (0, 1, 2), f'Invalid {venv=} should be 0, 1 or 2.' - elif arg in ('build', 'cibw', 'pyodide', 'test', 'wheel'): + elif arg in ('build', 'cibw', 'install', 'pyodide', 'test', 'wheel'): commands.append(arg) elif arg == 'buildtest': commands += ['build', 'test'] - elif arg == 'install': - _pymupdf = next(args) - commands.append(f'{arg}.{_pymupdf}') - else: assert 0, f'Unrecognised option/command: {arg=}.' @@ -530,9 +533,13 @@ def main(argv): # Build wheel(s) with cibuildwheel. cibuildwheel(env_extra, cibw_name, cibw_pyodide, cibw_sdist) - elif command.startswith('install.'): - name = command[len('install.'):] - run(f'pip install --force-reinstall {name}') + elif command == 'install': + p = 'pymupdf' + if install_version: + if not install_version.startswith(('==', '>=', '>')): + p = f'{p}==' + p = f'{p}{install_version}' + run(f'pip install --force-reinstall {p}') have_installed = True elif command == 'test': diff --git a/tests/resources/test_4496.hwpx b/tests/resources/test_4496.hwpx new file mode 100755 index 000000000..f1e0fb1a7 Binary files /dev/null and b/tests/resources/test_4496.hwpx differ diff --git a/tests/test_general.py b/tests/test_general.py index 1288c2279..b443df748 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -1907,3 +1907,9 @@ def test_4564(): assert document.metadata['producer'] == 'Adobe PSL 1.3e for Canon\x00' else: assert document.metadata['producer'] == 'Adobe PSL 1.3e for Canon\udcc0\udc80' + + +def test_4496(): + path = os.path.normpath(f'{__file__}/../../tests/resources/test_4496.hwpx') + with pymupdf.open(path) as document: + print(document.page_count)