[Python-checkins] cpython (3.3): Added base64 module tests for non-binary files.
serhiy.storchaka
python-checkins at python.org
Sun Apr 28 14:58:42 CEST 2013
http://hg.python.org/cpython/rev/95ca9b5ff402
changeset: 83533:95ca9b5ff402
branch: 3.3
parent: 83531:44edbea21640
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Apr 28 15:56:11 2013 +0300
summary:
Added base64 module tests for non-binary files.
files:
Lib/test/test_base64.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py
--- a/Lib/test/test_base64.py
+++ b/Lib/test/test_base64.py
@@ -45,7 +45,7 @@
def test_encode(self):
eq = self.assertEqual
- from io import BytesIO
+ from io import BytesIO, StringIO
infp = BytesIO(b'abcdefghijklmnopqrstuvwxyz'
b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
b'0123456789!@#0^&*();:<>,. []{}')
@@ -55,13 +55,21 @@
b'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE'
b'RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT'
b'Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n')
+ # Non-binary files
+ self.assertRaises(TypeError, base64.encode, StringIO('abc'), BytesIO())
+ self.assertRaises(TypeError, base64.encode, BytesIO(b'abc'), StringIO())
+ self.assertRaises(TypeError, base64.encode, StringIO('abc'), StringIO())
def test_decode(self):
- from io import BytesIO
+ from io import BytesIO, StringIO
infp = BytesIO(b'd3d3LnB5dGhvbi5vcmc=')
outfp = BytesIO()
base64.decode(infp, outfp)
self.assertEqual(outfp.getvalue(), b'www.python.org')
+ # Non-binary files
+ self.assertRaises(TypeError, base64.encode, StringIO('YWJj\n'), BytesIO())
+ self.assertRaises(TypeError, base64.encode, BytesIO(b'YWJj\n'), StringIO())
+ self.assertRaises(TypeError, base64.encode, StringIO('YWJj\n'), StringIO())
class BaseXYTestCase(unittest.TestCase):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list