Skip to content

Commit

Permalink
Update test_writer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan6419846 authored Aug 29, 2023
1 parent 8c9513d commit 52e4361
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
)

from . import get_data_from_url, is_sublist
from .test_images import image_similarity

TESTS_ROOT = Path(__file__).parent.resolve()
PROJECT_ROOT = TESTS_ROOT.parent
Expand Down Expand Up @@ -1563,15 +1564,20 @@ def test_watermark_rendering(tmp_path):
writer = PdfWriter(clone_from=BytesIO(get_data_from_url(url, name=name)))
writer.pages[0].merge_page(reader.pages[0], over=False)

target_png_path = tmp_path / "target.png"
target_png_path.write_bytes(get_data_from_url(
"https://github.com/stefan6419846/pypdf/assets/96178532/d0060a47-b454-4f84-bc76-68c87b6c2a76", name="dstwatermark.png"
))

pdf_path = tmp_path / "out.pdf"
png_path = tmp_path / "out.png"
writer.write(pdf_path)
# TODO: Use `shutil.which` beforehand.
# https://github.com/PyCQA/bandit/issues/333
subprocess.run(["gs", "-sDEVICE=pngalpha", "-o", png_path, pdf_path]) # noqa: S603,S607
assert png_path.is_file()
import shutil
shutil.copyfile(png_path, Path("/home/runner/work/pypdf/pypdf") / "file.png")
image_similarity(png_path, target_png_path)



@pytest.mark.enable_socket()
Expand Down

0 comments on commit 52e4361

Please sign in to comment.