diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-05-14 15:10:45 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-05-14 15:10:45 (GMT) |
commit | b78c448f4bad3afee409129337709e5fb110e5f3 (patch) | |
tree | 5360eae15e4d6e89c36ddc55df068fd80c2c5f38 /Lib | |
parent | ef5b4e3dc3b04327514d2e1704a8c8cd822d8beb (diff) | |
download | cpython-b78c448f4bad3afee409129337709e5fb110e5f3.zip cpython-b78c448f4bad3afee409129337709e5fb110e5f3.tar.gz cpython-b78c448f4bad3afee409129337709e5fb110e5f3.tar.bz2 |
Issue #21488: Add support of keyword arguments for codecs.encode and codecs.decode
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_codecs.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 9b62d5b..5aa2140 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1600,6 +1600,12 @@ class CodecsModuleTest(unittest.TestCase): self.assertEqual(codecs.decode(b'abc'), 'abc') self.assertRaises(UnicodeDecodeError, codecs.decode, b'\xff', 'ascii') + # test keywords + self.assertEqual(codecs.decode(obj=b'\xe4\xf6\xfc', encoding='latin-1'), + '\xe4\xf6\xfc') + self.assertEqual(codecs.decode(b'[\xff]', 'ascii', errors='ignore'), + '[]') + def test_encode(self): self.assertEqual(codecs.encode('\xe4\xf6\xfc', 'latin-1'), b'\xe4\xf6\xfc') @@ -1608,6 +1614,12 @@ class CodecsModuleTest(unittest.TestCase): self.assertEqual(codecs.encode('abc'), b'abc') self.assertRaises(UnicodeEncodeError, codecs.encode, '\xffff', 'ascii') + # test keywords + self.assertEqual(codecs.encode(obj='\xe4\xf6\xfc', encoding='latin-1'), + b'\xe4\xf6\xfc') + self.assertEqual(codecs.encode('[\xff]', 'ascii', errors='ignore'), + b'[]') + def test_register(self): self.assertRaises(TypeError, codecs.register) self.assertRaises(TypeError, codecs.register, 42) |