diff --git a/CHANGELOG.md b/CHANGELOG.md index b60cadb..f25e817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. The format - Add type annotations, and refactor parts of the library accordingly. - Add enforcement of type annotations via `mypy --strict`. +- Add final bits of test coverage. - Add `TableSettings` class, a behind-the-scenes handler for managing and validating table-extraction settings. ### Changed diff --git a/pdfplumber/display.py b/pdfplumber/display.py index b3eb0d6..91c3a24 100644 --- a/pdfplumber/display.py +++ b/pdfplumber/display.py @@ -10,7 +10,7 @@ from ._typing import T_bbox, T_num, T_obj, T_obj_list, T_point, T_seq from .table import T_table_settings, Table, TableFinder, TableSettings -if TYPE_CHECKING: +if TYPE_CHECKING: # pragma: nocover from pandas.core.frame import DataFrame from pandas.core.series import Series diff --git a/pdfplumber/pdf.py b/pdfplumber/pdf.py index 0e75f22..4f16e49 100644 --- a/pdfplumber/pdf.py +++ b/pdfplumber/pdf.py @@ -46,7 +46,7 @@ def __init__( for k, v in self.metadata.items(): try: self.metadata[k] = resolve_and_decode(v) - except Exception as e: + except Exception as e: # pragma: nocover if strict_metadata: # Raise an exception since unable to resolve the metadata value. raise diff --git a/tests/test_display.py b/tests/test_display.py index 1712338..053a94c 100644 --- a/tests/test_display.py +++ b/tests/test_display.py @@ -4,7 +4,10 @@ import os import unittest +import pytest + import pdfplumber +from pdfplumber.table import TableFinder logging.disable(logging.ERROR) @@ -34,6 +37,11 @@ def test_debug_tablefinder(self): self.im.reset() settings = {"horizontal_strategy": "text", "intersection_tolerance": 5} self.im.debug_tablefinder(settings) + finder = TableFinder(self.im.page, settings) + self.im.debug_tablefinder(finder) + + with pytest.raises(ValueError): + self.im.debug_tablefinder(0) def test_bytes_stream_to_image(self): path = os.path.join(HERE, "pdfs/nics-background-checks-2015-11.pdf") @@ -52,3 +60,20 @@ def test_cropped(self): def test_copy(self): assert self.im.copy().original == self.im.original + + def test_outline_words(self): + self.im.outline_words( + stroke="blue", + fill=(0, 200, 10), + stroke_width=2, + x_tolerance=5, + y_tolerance=5, + ) + + def test_outline_chars(self): + self.im.outline_chars(stroke="blue", fill=(0, 200, 10), stroke_width=2) + + def test__repr_png_(self): + png = self.im._repr_png_() + assert isinstance(png, bytes) + assert len(png) == 71948