summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2005-11-17 18:51:34 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2005-11-17 18:51:34 (GMT)
commit690402ff170abfc9b24269aa7db923eddf60e607 (patch)
treede6e027bd7e7d55a353e6a47b44f4249d2e62c86 /Lib/test/test_codecs.py
parenta53899272b71d90a2a2ade76532ff0b96d7ceed1 (diff)
downloadcpython-690402ff170abfc9b24269aa7db923eddf60e607.zip
cpython-690402ff170abfc9b24269aa7db923eddf60e607.tar.gz
cpython-690402ff170abfc9b24269aa7db923eddf60e607.tar.bz2
Add tests to increase code coverage in Python/codecs.c and Python/exceptions.c.
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 336696c..b344f9a 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -746,15 +746,34 @@ class CodecsModuleTest(unittest.TestCase):
self.assertEquals(codecs.encode(u'\xe4\xf6\xfc', 'latin-1'),
'\xe4\xf6\xfc')
self.assertRaises(TypeError, codecs.encode)
+ self.assertRaises(LookupError, codecs.encode, "foo", "__spam__")
self.assertEquals(codecs.encode(u'abc'), 'abc')
self.assertRaises(UnicodeEncodeError, codecs.encode, u'\xffff', 'ascii')
def test_register(self):
self.assertRaises(TypeError, codecs.register)
+ self.assertRaises(TypeError, codecs.register, 42)
def test_lookup(self):
self.assertRaises(TypeError, codecs.lookup)
self.assertRaises(LookupError, codecs.lookup, "__spam__")
+ self.assertRaises(LookupError, codecs.lookup, " ")
+
+ def test_getencoder(self):
+ self.assertRaises(TypeError, codecs.getencoder)
+ self.assertRaises(LookupError, codecs.getencoder, "__spam__")
+
+ def test_getdecoder(self):
+ self.assertRaises(TypeError, codecs.getdecoder)
+ self.assertRaises(LookupError, codecs.getdecoder, "__spam__")
+
+ def test_getreader(self):
+ self.assertRaises(TypeError, codecs.getreader)
+ self.assertRaises(LookupError, codecs.getreader, "__spam__")
+
+ def test_getwriter(self):
+ self.assertRaises(TypeError, codecs.getwriter)
+ self.assertRaises(LookupError, codecs.getwriter, "__spam__")
class StreamReaderTest(unittest.TestCase):