From 7524799411d9ffd701ad12ded2cf0d4bc3dd5387 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 18:10:26 +0200 Subject: Merging upstream version 0.10.0. Signed-off-by: Daniel Baumann --- tests/test_pydyf.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_pydyf.py b/tests/test_pydyf.py index 83c260c..ff63be2 100644 --- a/tests/test_pydyf.py +++ b/tests/test_pydyf.py @@ -1,4 +1,5 @@ import io +import re import pydyf @@ -704,11 +705,34 @@ def test_text(): ''') -def test_identifier(): +def test_no_identifier(): + document = pydyf.PDF() + pdf = io.BytesIO() + document.write(pdf, identifier=False) + assert re.search( + b'/ID \\[\\((?P[0-9a-f]{32})\\) \\((?P=hash)\\)\\]', + pdf.getvalue() + ) is None + + +def test_default_identifier(): + document = pydyf.PDF() + pdf = io.BytesIO() + document.write(pdf, identifier=True) + assert re.search( + b'/ID \\[\\((?P[0-9a-f]{32})\\) \\((?P=hash)\\)\\]', + pdf.getvalue() + ) is not None + + +def test_custom_identifier(): document = pydyf.PDF() pdf = io.BytesIO() document.write(pdf, identifier=b'abc') - assert b'abc' in pdf.getvalue() + assert re.search( + b'/ID \\[\\(abc\\) \\(([0-9a-f]{32})\\)\\]', + pdf.getvalue() + ) is not None def test_version(): -- cgit v1.2.3