diff --git a/tests/test.sh b/tests/test.sh index 987d8cd..67d196f 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." -python3 -m unittest discover -s tests -p 'test_plugin.py' -v +uv run --isolated --no-project --with pypdf==6.7.5 \ + python3 -m unittest discover -s tests -p 'test_plugin.py' -v python3 -m unittest discover -s plugins/consumables/tests -p 'test_plugin.py' -v plugins/diagnostics/tests/test.sh diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 42b16a9..019d905 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -5,6 +5,8 @@ import subprocess import tempfile import unittest +from pypdf import PdfReader + ROOT = Path(__file__).resolve().parents[1] @@ -14,7 +16,8 @@ class ReportPluginTests(unittest.TestCase): result = subprocess.run([str(root / 'build.sh'), 'render', 'report', str(source), '--output', str(output), '--force'], text=True, capture_output=True) self.assertEqual(result.returncode, 0, result.stderr) - return subprocess.check_output(['pdftotext', '-layout', str(output), '-'], text=True) + reader = PdfReader(output) + return '\n'.join(page.extract_text(extraction_mode='layout') for page in reader.pages) def test_localised_report_headings_and_authored_content(self): report = json.loads((ROOT / 'examples/example-report.json').read_text())