summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJames R. Barlow <jim@purplerock.ca>2018-07-13 22:48:15 -0700
committerJames R. Barlow <jim@purplerock.ca>2018-07-13 22:48:15 -0700
commit3d1481826e236f753a45f3c071ccc6a6fb65102a (patch)
treee4b9d54aa8e2a466b716d1d1d71cd13241e77fed /tests
parent656df0caa2cfb0a2e33ab338aa8f6c428b6ca6ce (diff)
Improve dictionary construction interface and more not-convertibles
Diffstat (limited to 'tests')
-rw-r--r--tests/test_object.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/test_object.py b/tests/test_object.py
index 159f94b..3db73d0 100644
--- a/tests/test_object.py
+++ b/tests/test_object.py
@@ -237,8 +237,22 @@ def test_dictionary_none():
d['/Two'] = None
+def test_dictionary_init():
+ d1 = pikepdf.Dictionary({'/Animal': 'Dog'})
+ d2 = pikepdf.Dictionary(Animal='Dog')
+ assert d1 == d2
+
+
def test_not_convertible():
- class C:
- pass
+ class PurePythonObj:
+ def __repr__(self):
+ return 'PurePythonObj()'
+ c = PurePythonObj()
+ with pytest.raises(RuntimeError):
+ encode(c)
+ with pytest.raises(RuntimeError):
+ pikepdf.Array([1, 2, c])
+
+ d = pikepdf.Dictionary()
with pytest.raises(RuntimeError):
- encode(C())
+ d.SomeKey = c