From 2521f1858f5483c1f384f47b6253d71aefbb57c9 Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Mon, 22 Jan 2018 14:35:32 +0800 Subject: [PATCH 1/2] bpo-32618: Fix test_mutatingdecodehandler not testing test.mutating It should test both test.replacing and test.mutating instead of test test.replacing twice. --- Lib/test/test_codeccallbacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 6a3e993265687bf..18d026004651030 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -1043,7 +1043,7 @@ def mutating(exc): # unicode-internal has been deprecated for (encoding, data) in baddata: with self.assertRaises(TypeError): - data.decode(encoding, "test.replacing") + data.decode(encoding, "test.mutating") def test_fake_error_class(self): handlers = [ From 6df0f657388e8aeec157b95e1faecc7fd3ef4a1d Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Mon, 22 Jan 2018 16:10:12 +0800 Subject: [PATCH 2/2] make test.mutating more meaningful --- Lib/test/test_codeccallbacks.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 18d026004651030..0c066e633fa846d 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -1032,7 +1032,7 @@ def replacing(exc): 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 @@ def mutating(exc): with test.support.check_warnings(): # unicode-internal has been deprecated for (encoding, data) in baddata: - with self.assertRaises(TypeError): - data.decode(encoding, "test.mutating") + self.assertEqual(data.decode(encoding, "test.mutating"), "\u4242") def test_fake_error_class(self): handlers = [