diff options
author | James R. Barlow <jim@purplerock.ca> | 2019-04-13 00:59:21 -0700 |
---|---|---|
committer | James R. Barlow <jim@purplerock.ca> | 2019-04-13 00:59:21 -0700 |
commit | 93492e8fa0b962331033f7b12726ed849389aec2 (patch) | |
tree | 038e28f0a0d302cf98c2be86d96bc62622c7b19f /tests | |
parent | ae98e501804cdde026e6719e98b9dba9beeb75a7 (diff) |
Implement Pdf.close() and context manager
We still have the possibility of reference counting holding a Pdf
object open, but at least provide an API so the caller can explicitly close
it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_pdf.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_pdf.py b/tests/test_pdf.py index 5c80847..9c4ec60 100644 --- a/tests/test_pdf.py +++ b/tests/test_pdf.py @@ -217,3 +217,10 @@ def test_object_stream_mode_generated(trivial, outdir): object_stream_mode=pikepdf.ObjectStreamMode.generate, ) assert b'/ObjStm' in Path(outdir / '2.pdf').read_bytes() + + +def test_with_block(resources): + desc = '' + with pikepdf.open(resources / 'pal-1bit-trivial.pdf') as pdf: + desc = pdf.filename + assert pdf.filename != desc |