mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix some tests by deleting stuff.
This commit is contained in:
parent
8518bdc382
commit
f903f00ee2
4 changed files with 1 additions and 56 deletions
|
@ -1096,58 +1096,6 @@ class MixinStrUnicodeUserStringTest:
|
|||
self.checkraises(TypeError, S, 'rpartition', None)
|
||||
|
||||
|
||||
class MixinStrStringUserStringTest:
|
||||
# Additional tests for 8bit strings, i.e. str, UserString and
|
||||
# the string module
|
||||
|
||||
def test_maketrans(self):
|
||||
self.assertEqual(
|
||||
''.join(map(chr, range(256))).replace('abc', 'xyz'),
|
||||
string.maketrans('abc', 'xyz')
|
||||
)
|
||||
self.assertRaises(ValueError, string.maketrans, 'abc', 'xyzw')
|
||||
|
||||
def test_translate(self):
|
||||
table = string.maketrans('abc', 'xyz')
|
||||
self.checkequal('xyzxyz', 'xyzabcdef', 'translate', table, 'def')
|
||||
|
||||
table = string.maketrans('a', 'A')
|
||||
self.checkequal('Abc', 'abc', 'translate', table)
|
||||
self.checkequal('xyz', 'xyz', 'translate', table)
|
||||
self.checkequal('yz', 'xyz', 'translate', table, 'x')
|
||||
self.checkequal('yx', 'zyzzx', 'translate', None, 'z')
|
||||
self.checkequal('zyzzx', 'zyzzx', 'translate', None, '')
|
||||
self.checkequal('zyzzx', 'zyzzx', 'translate', None)
|
||||
self.checkraises(ValueError, 'xyz', 'translate', 'too short', 'strip')
|
||||
self.checkraises(ValueError, 'xyz', 'translate', 'too short')
|
||||
|
||||
|
||||
class MixinStrUserStringTest:
|
||||
# Additional tests that only work with
|
||||
# 8bit compatible object, i.e. str and UserString
|
||||
|
||||
def test_encoding_decoding(self):
|
||||
codecs = [('rot13', b'uryyb jbeyq'),
|
||||
('base64', b'aGVsbG8gd29ybGQ=\n'),
|
||||
('hex', b'68656c6c6f20776f726c64'),
|
||||
('uu', b'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)
|
||||
# zlib is optional, so we make the test optional too...
|
||||
try:
|
||||
import zlib
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
data = b'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')
|
||||
|
||||
self.checkraises(TypeError, 'xyz', 'decode', 42)
|
||||
self.checkraises(TypeError, 'xyz', 'encode', 42)
|
||||
|
||||
|
||||
class MixinStrUnicodeTest:
|
||||
# Additional tests that only work with str and unicode.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue