From 0f50bc34d1ad04408b0c3eda961e559302ecc5fe Mon Sep 17 00:00:00 2001 From: bosd Date: Thu, 23 Feb 2023 19:49:29 +0100 Subject: [PATCH] Skip test if pdfplumber is not available --- tests/test_lib.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_lib.py b/tests/test_lib.py index 23ff7d83..7ebf3047 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -24,6 +24,17 @@ from .common import get_sample_files +def have_pdfplumber(): + try: + import pdfplumber # noqa: F401 + except ImportError: + return False + return True + + +needs_pdfplumber = unittest.skipIf(not have_pdfplumber(), reason="requires pdfplumber\n") + + def _extract_data_for_export(): pdf_files = get_sample_files('.pdf') for file in pdf_files: @@ -87,6 +98,7 @@ def test_extract_data_pdfminer(self): self.assertTrue(False, "pdfminer is not installed") self.assertTrue(type(res) is str, "return is not a string") + @needs_pdfplumber def test_extract_data_pdfplumber(self): pdf_files = get_sample_files('.pdf') for file in pdf_files: