diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-04-28 12:56:11 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-04-28 12:56:11 (GMT) |
commit | abac0a7744c6c317821935f86a342a44cba1aaaf (patch) | |
tree | e9d5b6abb24e05ce1f7e5833ce5c4af468f12f37 /Lib | |
parent | 017523c4f486b82ac8d53e346bc87caadaf52df2 (diff) | |
download | cpython-abac0a7744c6c317821935f86a342a44cba1aaaf.zip cpython-abac0a7744c6c317821935f86a342a44cba1aaaf.tar.gz cpython-abac0a7744c6c317821935f86a342a44cba1aaaf.tar.bz2 |
Added base64 module tests for non-binary files.
Diffstat (limited to 'Lib')
-rw-r--r-- | 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 index 7ba1fe7..abba5bf 100644 --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -45,7 +45,7 @@ class LegacyBase64TestCase(unittest.TestCase): 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 @@ class LegacyBase64TestCase(unittest.TestCase): 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): |