Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_open_pdf_no_password_but_needed(self, resources):
with pytest.raises(PasswordError):
Pdf.open(resources / 'graph-encrypted.pdf')
def test_memory(self, resources):
pdf = (resources / 'pal-1bit-trivial.pdf').read_bytes()
with pytest.raises(Exception):
pdf = Pdf.open(pdf)
def graph(resources):
# Has XMP and docinfo, all standard format XMP
return Pdf.open(resources / 'graph.pdf')
def test_roundtrip(filename):
try:
pdf = Pdf.open(filename)
except PasswordError:
return
with pdf.open_metadata() as xmp:
for k in xmp.keys():
if not 'Date' in k:
xmp[k] = 'A'
assert '
def test_update_info(graph, outdir):
new_title = '我敢打赌,你只是想看看这意味着什么'
graph.docinfo['/Title'] = new_title
graph.save(outdir / 'out.pdf')
new = Pdf.open(outdir / 'out.pdf')
assert new.docinfo['/Title'] == new_title
assert graph.docinfo['/Author'] == new.docinfo['/Author']
with pytest.raises(ValueError):
new.docinfo = Dictionary({'/Keywords': 'bob'})
new.docinfo = graph.make_indirect(Dictionary({'/Keywords': 'bob'}))
assert new.docinfo.is_indirect, "/Info must be an indirect object"