def test_pdf_repr(self): self.assertEqual(bytes(IndirectReference(1, 2)), b"1 2 R") self.assertEqual(bytes(IndirectObjectDef(*IndirectReference(1, 2))), b"1 2 obj") self.assertEqual(bytes(PdfName(b"Name#Hash")), b"/Name#23Hash") self.assertEqual(bytes(PdfName("Name#Hash")), b"/Name#23Hash") self.assertEqual(bytes(PdfDict({b"Name": IndirectReference(1, 2)})), b"<<\n/Name 1 2 R\n>>") self.assertEqual(bytes(PdfDict({"Name": IndirectReference(1, 2)})), b"<<\n/Name 1 2 R\n>>") self.assertEqual(pdf_repr(IndirectReference(1, 2)), b"1 2 R") self.assertEqual(pdf_repr(IndirectObjectDef(*IndirectReference(1, 2))), b"1 2 obj") self.assertEqual(pdf_repr(PdfName(b"Name#Hash")), b"/Name#23Hash") self.assertEqual(pdf_repr(PdfName("Name#Hash")), b"/Name#23Hash") self.assertEqual(pdf_repr(PdfDict({b"Name": IndirectReference(1, 2)})), b"<<\n/Name 1 2 R\n>>") self.assertEqual(pdf_repr(PdfDict({"Name": IndirectReference(1, 2)})), b"<<\n/Name 1 2 R\n>>") self.assertEqual(pdf_repr(123), b"123") self.assertEqual(pdf_repr(True), b"true") self.assertEqual(pdf_repr(False), b"false") self.assertEqual(pdf_repr(None), b"null") self.assertEqual(pdf_repr(b"a)/b\\(c"), br"(a\)/b\\\(c)") self.assertEqual(pdf_repr([123, True, { "a": PdfName(b"b") }]), b"[ 123 true <<\n/a /b\n>> ]") self.assertEqual(pdf_repr(PdfBinary(b"\x90\x1F\xA0")), b"<901FA0>")
def test_pdf_repr(): assert bytes(IndirectReference(1, 2)) == b"1 2 R" assert bytes(IndirectObjectDef(*IndirectReference(1, 2))) == b"1 2 obj" assert bytes(PdfName(b"Name#Hash")) == b"/Name#23Hash" assert bytes(PdfName("Name#Hash")) == b"/Name#23Hash" assert bytes(PdfDict({b"Name": IndirectReference(1, 2)})) == b"<<\n/Name 1 2 R\n>>" assert bytes(PdfDict({"Name": IndirectReference(1, 2)})) == b"<<\n/Name 1 2 R\n>>" assert pdf_repr(IndirectReference(1, 2)) == b"1 2 R" assert pdf_repr(IndirectObjectDef(*IndirectReference(1, 2))) == b"1 2 obj" assert pdf_repr(PdfName(b"Name#Hash")) == b"/Name#23Hash" assert pdf_repr(PdfName("Name#Hash")) == b"/Name#23Hash" assert (pdf_repr(PdfDict({b"Name": IndirectReference(1, 2) })) == b"<<\n/Name 1 2 R\n>>") assert (pdf_repr(PdfDict({"Name": IndirectReference(1, 2) })) == b"<<\n/Name 1 2 R\n>>") assert pdf_repr(123) == b"123" assert pdf_repr(True) == b"true" assert pdf_repr(False) == b"false" assert pdf_repr(None) == b"null" assert pdf_repr(b"a)/b\\(c") == rb"(a\)/b\\\(c)" assert pdf_repr([123, True, { "a": PdfName(b"b") }]) == b"[ 123 true <<\n/a /b\n>> ]" assert pdf_repr(PdfBinary(b"\x90\x1F\xA0")) == b"<901FA0>"
def test_indirect_refs(self): self.assertEqual(IndirectReference(1, 2), IndirectReference(1, 2)) self.assertNotEqual(IndirectReference(1, 2), IndirectReference(1, 3)) self.assertNotEqual(IndirectReference(1, 2), IndirectObjectDef(1, 2)) self.assertNotEqual(IndirectReference(1, 2), (1, 2)) self.assertEqual(IndirectObjectDef(1, 2), IndirectObjectDef(1, 2)) self.assertNotEqual(IndirectObjectDef(1, 2), IndirectObjectDef(1, 3)) self.assertNotEqual(IndirectObjectDef(1, 2), IndirectReference(1, 2)) self.assertNotEqual(IndirectObjectDef(1, 2), (1, 2))
def test_indirect_refs(): assert IndirectReference(1, 2) == IndirectReference(1, 2) assert IndirectReference(1, 2) != IndirectReference(1, 3) assert IndirectReference(1, 2) != IndirectObjectDef(1, 2) assert IndirectReference(1, 2) != (1, 2) assert IndirectObjectDef(1, 2) == IndirectObjectDef(1, 2) assert IndirectObjectDef(1, 2) != IndirectObjectDef(1, 3) assert IndirectObjectDef(1, 2) != IndirectReference(1, 2) assert IndirectObjectDef(1, 2) != (1, 2)