def test_open_from_corrupted_bytes_throws_error(self): with self.assertRaisesRegexp(ValueError, 'invalid pdf file'): PDFDocument.frombytes(b'foo')
def test_open_from_buffer(self): with open('tests/assets/1page.pdf', 'rb') as f: doc = PDFDocument.frombytes(f.read()) self.assertIsNotNone(doc) self.assertEqual(len(doc), 1)