Ignore unpaper warning message when checking version

Fixes #1409
This commit is contained in:
James R. Barlow 2024-10-27 13:06:30 -07:00
parent 706681deb8
commit 6f755321b8
No known key found for this signature in database
GPG Key ID: E54A300D567E1260
2 changed files with 15 additions and 2 deletions

View File

@ -48,7 +48,7 @@ class UnpaperImageTooLargeError(Exception):
def version() -> Version:
return Version(get_version('unpaper'))
return Version(get_version('unpaper', regex=r'(?m).*(\d+(\.\d+)(\.\d+)?)'))
@contextmanager

View File

@ -5,7 +5,7 @@ from __future__ import annotations
import logging
from os import fspath
from unittest.mock import patch
from unittest.mock import Mock, patch
import pytest
from packaging.version import Version
@ -48,6 +48,19 @@ def test_old_unpaper(resources, no_outpdf):
mock.assert_called()
def test_unpaper_version_chatter(resources, no_outpdf):
input_ = fspath(resources / "c02-22.pdf")
output = fspath(no_outpdf)
_parser, options, pm = get_parser_options_plugins(["--clean", input_, output])
with patch("ocrmypdf.subprocess.run") as mock:
mock.return_value = Mock(stdout='Warning: using insecure memory!\n7.0.0\n')
with pytest.raises(MissingDependencyError):
check_options(options, pm)
mock.assert_called()
@needs_unpaper
def test_clean(resources, outpdf):
check_ocrmypdf(