From 063e1e846dc5c3fe593cef5b14cc429369dcd2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walter=20D=C3=B6rwald?= Date: Thu, 28 Oct 2004 13:04:26 +0000 Subject: Trigger a few error cases in Modules/_codecsmodule.c. --- Lib/test/test_codecs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 54d9da5..21ae467 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -454,9 +454,23 @@ class CodecsModuleTest(unittest.TestCase): def test_decode(self): self.assertEquals(codecs.decode('\xe4\xf6\xfc', 'latin-1'), u'\xe4\xf6\xfc') + self.assertRaises(TypeError, codecs.decode) + self.assertEquals(codecs.decode('abc'), u'abc') + self.assertRaises(UnicodeDecodeError, codecs.decode, '\xff', 'ascii') + def test_encode(self): self.assertEquals(codecs.encode(u'\xe4\xf6\xfc', 'latin-1'), '\xe4\xf6\xfc') + self.assertRaises(TypeError, codecs.encode) + self.assertEquals(codecs.encode(u'abc'), 'abc') + self.assertRaises(UnicodeEncodeError, codecs.encode, u'\xffff', 'ascii') + + def test_register(self): + self.assertRaises(TypeError, codecs.register) + + def test_lookup(self): + self.assertRaises(TypeError, codecs.lookup) + self.assertRaises(LookupError, codecs.lookup, "__spam__") class StreamReaderTest(unittest.TestCase): -- cgit v0.12