[Python-3000-checkins] r55355 - in python/branches/py3k-struni/Lib: encodings/base64_codec.py test/string_tests.py test/test_str.py
guido.van.rossum
python-3000-checkins at python.org
Tue May 15 23:10:33 CEST 2007
Author: guido.van.rossum
Date: Tue May 15 23:10:24 2007
New Revision: 55355
Modified:
python/branches/py3k-struni/Lib/encodings/base64_codec.py
python/branches/py3k-struni/Lib/test/string_tests.py
python/branches/py3k-struni/Lib/test/test_str.py
Log:
Make test_str.py pass.
Modified: python/branches/py3k-struni/Lib/encodings/base64_codec.py
==============================================================================
--- python/branches/py3k-struni/Lib/encodings/base64_codec.py (original)
+++ python/branches/py3k-struni/Lib/encodings/base64_codec.py Tue May 15 23:10:24 2007
@@ -21,7 +21,7 @@
"""
assert errors == 'strict'
- output = base64.encodestring(input)
+ output = bytes(base64.encodestring(input))
return (output, len(input))
def base64_decode(input,errors='strict'):
Modified: python/branches/py3k-struni/Lib/test/string_tests.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/string_tests.py (original)
+++ python/branches/py3k-struni/Lib/test/string_tests.py Tue May 15 23:10:24 2007
@@ -1102,10 +1102,10 @@
if test_support.have_unicode:
def test_encoding_decoding(self):
- codecs = [('rot13', 'uryyb jbeyq'),
- ('base64', 'aGVsbG8gd29ybGQ=\n'),
- ('hex', '68656c6c6f20776f726c64'),
- ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')]
+ 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)
@@ -1115,7 +1115,7 @@
except ImportError:
pass
else:
- data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]'
+ 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')
Modified: python/branches/py3k-struni/Lib/test/test_str.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_str.py (original)
+++ python/branches/py3k-struni/Lib/test/test_str.py Tue May 15 23:10:24 2007
@@ -29,9 +29,6 @@
def test_conversion(self):
# Make sure __str__() behaves properly
- class Foo0:
- def __unicode__(self):
- return "foo"
class Foo1:
def __str__(self):
@@ -45,15 +42,15 @@
def __str__(self):
return "foo"
- class Foo4(str):
+ class Foo4(str8):
def __str__(self):
return "foo"
class Foo5(str):
- def __str__(self):
+ def __unicode__(self):
return "foo"
- class Foo6(str):
+ class Foo6(str8):
def __str__(self):
return "foos"
@@ -72,22 +69,23 @@
def __str__(self):
return self
- class Foo9(str):
+ class Foo9(str8):
def __str__(self):
return "string"
def __unicode__(self):
return "not unicode"
- self.assert_(str(Foo0()).startswith("<")) # this is different from __unicode__
self.assertEqual(str(Foo1()), "foo")
self.assertEqual(str(Foo2()), "foo")
self.assertEqual(str(Foo3()), "foo")
self.assertEqual(str(Foo4("bar")), "foo")
self.assertEqual(str(Foo5("bar")), "foo")
- self.assertEqual(str(Foo6("bar")), "foos")
- self.assertEqual(str(Foo7("bar")), "foos")
+ self.assertEqual(str8(Foo6("bar")), "foos")
+ self.assertEqual(str(Foo6("bar")), "foou")
+ self.assertEqual(str8(Foo7("bar")), "foos")
+ self.assertEqual(str(Foo7("bar")), "foou")
self.assertEqual(str(Foo8("foo")), "foofoo")
- self.assertEqual(str(Foo9("foo")), "string")
+ self.assertEqual(str8(Foo9("foo")), "string")
self.assertEqual(str(Foo9("foo")), "not unicode")
def test_main():
More information about the Python-3000-checkins
mailing list