Skip to content

Commit

Permalink
Ignore unpaper warning message when checking version
Browse files Browse the repository at this point in the history
Fixes #1409
  • Loading branch information
jbarlow83 committed Oct 27, 2024
1 parent 706681d commit 6f75532
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ocrmypdf/_exec/unpaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(


def version() -> Version:
return Version(get_version('unpaper'))
return Version(get_version('unpaper', regex=r'(?m).*(\d+(\.\d+)(\.\d+)?)'))


@contextmanager
Expand Down
15 changes: 14 additions & 1 deletion tests/test_unpaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import logging
from os import fspath
from unittest.mock import patch
from unittest.mock import Mock, patch

import pytest
from packaging.version import Version
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6f75532

Please sign in to comment.