Commit 6eea789f authored by Walter Dörwald's avatar Walter Dörwald

Disable encoding/decoding test, if unicode is disabled.

parent 97bb8ad3
...@@ -737,26 +737,27 @@ class MixinStrUserStringTest: ...@@ -737,26 +737,27 @@ class MixinStrUserStringTest:
# Additional tests that only work with # Additional tests that only work with
# 8bit compatible object, i.e. str and UserString # 8bit compatible object, i.e. str and UserString
def test_encoding_decoding(self): if test_support.have_unicode:
codecs = [('rot13', 'uryyb jbeyq'), def test_encoding_decoding(self):
('base64', 'aGVsbG8gd29ybGQ=\n'), codecs = [('rot13', 'uryyb jbeyq'),
('hex', '68656c6c6f20776f726c64'), ('base64', 'aGVsbG8gd29ybGQ=\n'),
('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')] ('hex', '68656c6c6f20776f726c64'),
for encoding, data in codecs: ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')]
self.checkequal(data, 'hello world', 'encode', encoding) for encoding, data in codecs:
self.checkequal('hello world', data, 'decode', encoding) self.checkequal(data, 'hello world', 'encode', encoding)
# zlib is optional, so we make the test optional too... self.checkequal('hello world', data, 'decode', encoding)
try: # zlib is optional, so we make the test optional too...
import zlib try:
except ImportError: import zlib
pass except ImportError:
else: pass
data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' else:
self.checkequal(data, 'hello world', 'encode', 'zlib') data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]'
self.checkequal('hello world', data, 'decode', 'zlib') self.checkequal(data, 'hello world', 'encode', 'zlib')
self.checkequal('hello world', data, 'decode', 'zlib')
self.checkraises(TypeError, 'xyz', 'decode', 42) self.checkraises(TypeError, 'xyz', 'decode', 42)
self.checkraises(TypeError, 'xyz', 'encode', 42) self.checkraises(TypeError, 'xyz', 'encode', 42)
class MixinStrUnicodeTest: class MixinStrUnicodeTest:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment