summaryrefslogtreecommitdiff
path: root/Lib/test/string_tests.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-31 20:21:00 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-31 20:21:00 +0300
commitc7797dc7482035ee166ca2e941b623382b92e1fc (patch)
tree526e26fa4dac506f02859fdbe946d33ed4165f5e /Lib/test/string_tests.py
parentcfb7028df4bdf12325786e48ebef3b4982efa119 (diff)
downloadcpython-git-c7797dc7482035ee166ca2e941b623382b92e1fc.tar.gz
Issue #19543: Emit deprecation warning for known non-text encodings.
Backported issues #19619: encode() and decode() methods and constructors of str, unicode and bytearray classes now emit deprecation warning for known non-text encodings when Python is ran with the -3 option. Backported issues #20404: io.TextIOWrapper (and hence io.open()) now uses the internal codec marking system added to emit deprecation warning for known non-text encodings at stream construction time when Python is ran with the -3 option.
Diffstat (limited to 'Lib/test/string_tests.py')
-rw-r--r--Lib/test/string_tests.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 6d87eb6957..b2f837bab6 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1295,8 +1295,10 @@ class MixinStrUserStringTest:
('hex', '68656c6c6f20776f726c64'),
('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')]
for encoding, data in codecs:
- self.checkequal(data, 'hello world', 'encode', encoding)
- self.checkequal('hello world', data, 'decode', encoding)
+ with test_support.check_py3k_warnings():
+ self.checkequal(data, 'hello world', 'encode', encoding)
+ with test_support.check_py3k_warnings():
+ self.checkequal('hello world', data, 'decode', encoding)
# zlib is optional, so we make the test optional too...
try:
import zlib
@@ -1304,8 +1306,10 @@ class MixinStrUserStringTest:
pass
else:
data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]'
- self.checkequal(data, 'hello world', 'encode', 'zlib')
- self.checkequal('hello world', data, 'decode', 'zlib')
+ with test_support.check_py3k_warnings():
+ self.checkequal(data, 'hello world', 'encode', 'zlib')
+ with test_support.check_py3k_warnings():
+ self.checkequal('hello world', data, 'decode', 'zlib')
self.checkraises(TypeError, 'xyz', 'decode', 42)
self.checkraises(TypeError, 'xyz', 'encode', 42)