Browse Source

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]
python2
John-Mark Gurney 8 years ago
parent
commit
e084525581
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      pasn1.py

+ 3
- 1
pasn1.py View File

@@ -325,7 +325,7 @@ class ASN1Coder(object):
tf = self._typemap[type(obj)] tf = self._typemap[type(obj)]
except KeyError: except KeyError:
if self.coerce is None: if self.coerce is None:
raise
raise TypeError('unhandled object: %s' % `obj`)


tf, obj = self.coerce(obj) tf, obj = self.coerce(obj)


@@ -580,5 +580,7 @@ class TestCode(unittest.TestCase):
self.assertEqual(ac.loads(es), v) self.assertEqual(ac.loads(es), v)
self.assertIsInstance(es, bytes) self.assertIsInstance(es, bytes)


self.assertRaises(TypeError, dumps, o)

def test_loads(self): def test_loads(self):
self.assertRaises(ValueError, loads, '\x00\x02\x00') self.assertRaises(ValueError, loads, '\x00\x02\x00')

Loading…
Cancel
Save