Add generic codecs.encode() and .decode() APIs that don't impose

any restriction on the return type (like unicode.encode() et al. do).
This commit is contained in:
Marc-André Lemburg 2004-07-10 12:06:10 +00:00
parent 126b44cd41
commit 3f41974525
2 changed files with 83 additions and 5 deletions

View file

@ -336,6 +336,15 @@ class CodecTest(unittest.TestCase):
def test_builtin(self):
self.assertEquals(unicode("python.org", "idna"), u"python.org")
class CodecsModuleTest(unittest.TestCase):
def test_decode(self):
self.assertEquals(codecs.decode('\xe4\xf6\xfc', 'latin-1'),
u'\xe4\xf6\xfc')
def test_encode(self):
self.assertEquals(codecs.encode(u'\xe4\xf6\xfc', 'latin-1'),
'\xe4\xf6\xfc')
def test_main():
test_support.run_unittest(
UTF16Test,
@ -343,7 +352,8 @@ def test_main():
RecodingTest,
PunycodeTest,
NameprepTest,
CodecTest
CodecTest,
CodecsModuleTest
)