summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pydyf.py28
1 files changed, 26 insertions, 2 deletions
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<hash>[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<hash>[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():