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_unequal_but_similar(self):
assert Name('/Foo') != String('/Foo')
def test_bytes():
b = b'\x79\x78\x77\x76'
qs = String(b)
assert bytes(qs) == b
s = 'é'
qs = String(s)
assert str(qs) == s
def test_repr_dict(self):
d = Dictionary({
'/Boolean': True,
'/Integer': 42,
'/Real': Decimal('42.42'),
'/String': String('hi'),
'/Array': Array([1, 2, 3]),
'/Operator': Operator('q'),
'/Dictionary': Dictionary({'/Color': 'Red'})
})
expected = """\
pikepdf.Dictionary({
"/Array": [ 1, 2, 3 ],
"/Boolean": True,
"/Dictionary": {
"/Color": "Red"
},
"/Integer": 42,
"/Operator": pikepdf.Operator("q"),
"/Real": Decimal('42.42'),
"/String": "hi"
})
def test_string(self):
utf16 = b'\xfe\xff' + 'hello'.encode('utf-16be')
self.check(String(utf16), String('hello'))
def test_bytes():
b = b'\x79\x78\x77\x76'
qs = String(b)
assert bytes(qs) == b
s = 'é'
qs = String(s)
assert str(qs) == s
def test_repr_scalar(self):
scalars = [
False,
666,
Decimal('3.14'),
String('scalar'),
Name('/Bob'),
Operator('Q')
]
for s in scalars:
assert eval(repr(s)) == s