Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
abac0a77
Commit
abac0a77
authored
Apr 28, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added base64 module tests for non-binary files.
parent
017523c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
Lib/test/test_base64.py
Lib/test/test_base64.py
+10
-2
No files found.
Lib/test/test_base64.py
View file @
abac0a77
...
...
@@ -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
\
n
NT'
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment