From e0845255811323be90da7571ce2faad2c82f3876 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Fri, 19 Feb 2016 17:18:53 -0800 Subject: [PATCH] add test to assert that a TypeError is raised when an unknown object is dump'd.. [git-p4: depot-paths = "//depot/python/pypasn1/main/": change = 1830] --- pasn1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pasn1.py b/pasn1.py index 367fff4..d970c89 100644 --- a/pasn1.py +++ b/pasn1.py @@ -325,7 +325,7 @@ class ASN1Coder(object): tf = self._typemap[type(obj)] except KeyError: if self.coerce is None: - raise + raise TypeError('unhandled object: %s' % `obj`) tf, obj = self.coerce(obj) @@ -580,5 +580,7 @@ class TestCode(unittest.TestCase): self.assertEqual(ac.loads(es), v) self.assertIsInstance(es, bytes) + self.assertRaises(TypeError, dumps, o) + def test_loads(self): self.assertRaises(ValueError, loads, '\x00\x02\x00')