]> granicus.if.org Git - python/commitdiff
bpo-32618: Fix test_mutatingdecodehandler not testing test.mutating (GH-5269) (#5285)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 23 Jan 2018 15:47:15 +0000 (07:47 -0800)
committerXiang Zhang <angwerzx@126.com>
Tue, 23 Jan 2018 15:47:15 +0000 (23:47 +0800)
It should test both test.replacing and test.mutating instead of test test.replacing twice.
(cherry picked from commit 370d04d1dcca50a52d59f40aff4d11434f71df6b)

Lib/test/test_codeccallbacks.py

index 6a3e993265687bfc83fe0c95ee67afd7f03f548a..0c066e633fa846d28218caaa02dd6ec2cda2eefa 100644 (file)
@@ -1032,7 +1032,7 @@ class CodecCallbackTest(unittest.TestCase):
 
         def mutating(exc):
             if isinstance(exc, UnicodeDecodeError):
-                exc.object[:] = b""
+                exc.object = b""
                 return ("\u4242", 0)
             else:
                 raise TypeError("don't know how to handle %r" % exc)
@@ -1042,8 +1042,7 @@ class CodecCallbackTest(unittest.TestCase):
         with test.support.check_warnings():
             # unicode-internal has been deprecated
             for (encoding, data) in baddata:
-                with self.assertRaises(TypeError):
-                    data.decode(encoding, "test.replacing")
+                self.assertEqual(data.decode(encoding, "test.mutating"), "\u4242")
 
     def test_fake_error_class(self):
         handlers = [