Detect veraPDF when version line is preceded by JVM warnings

This commit is contained in:
James R. Barlow
2026-06-30 01:03:02 -07:00
parent efe83e8c54
commit 7512b1042a
2 changed files with 36 additions and 9 deletions
+27 -6
View File
@@ -100,9 +100,9 @@ def test_redo_ocr(resources, outpdf):
out = check_ocrmypdf(in_, out, '--redo-ocr')
after = PdfInfo(out, detailed_analysis=True)
assert before[0].has_text and after[0].has_text
assert (
before[0].get_textareas() != after[0].get_textareas()
), "Expected text to be different after re-OCR"
assert before[0].get_textareas() != after[0].get_textareas(), (
"Expected text to be different after re-OCR"
)
def test_argsfile(resources, outdir):
@@ -768,9 +768,9 @@ def test_sidecar_pagecount(resources, outpdf):
# There should a formfeed between each pair of pages, so the count of
# formfeeds is the page count less one
assert (
ocr_text.count('\f') == num_pages - 1
), "Sidecar page count does not match PDF page count"
assert ocr_text.count('\f') == num_pages - 1, (
"Sidecar page count does not match PDF page count"
)
def test_sidecar_nonempty(resources, outpdf):
@@ -889,6 +889,27 @@ def test_version_check():
get_version('echo')
def test_get_version_skips_leading_warning_lines(monkeypatch):
"""VeraPDF 1.30.0 prints JVM warnings before its version line."""
from subprocess import CompletedProcess
import ocrmypdf.subprocess as sp
output = (
"WARNING: Final field flavour has been mutated reflectively\n"
"WARNING: Use --enable-final-field-mutation=ALL-UNNAMED to avoid this\n"
"veraPDF 1.30.0\n"
"Built: Wed Jun 03 13:29:00 PDT 2026\n"
)
def fake_run(args, **kwargs):
return CompletedProcess(args, 0, stdout=output, stderr="")
monkeypatch.setattr(sp, 'run', fake_run)
version = get_version('verapdf', regex=r'veraPDF (\d+(\.\d+)*)')
assert version == '1.30.0'
@pytest.mark.parametrize(
'threshold, optimize, output_type, expected',
[