mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
126b44cd41
commit
3f41974525
2 changed files with 83 additions and 5 deletions
|
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue