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
2ae87539
Commit
2ae87539
authored
May 18, 2002
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Mitchell Surface's regression tests for base64. Closes patch #550002.
parent
18ca7910
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
Lib/test/test_base64.py
Lib/test/test_base64.py
+59
-0
No files found.
Lib/test/test_base64.py
0 → 100644
View file @
2ae87539
import
unittest
import
test_support
import
base64
from
binascii
import
Error
as
binascii_error
class
Base64TestCase
(
unittest
.
TestCase
):
def
test_encode_string
(
self
):
"""Testing encode string"""
test_support
.
verify
(
base64
.
encodestring
(
"www.python.org"
)
==
"d3d3LnB5dGhvbi5vcmc=
\
n
"
,
reason
=
"www.python.org encodestring failed"
)
test_support
.
verify
(
base64
.
encodestring
(
"a"
)
==
"YQ==
\
n
"
,
reason
=
"a encodestring failed"
)
test_support
.
verify
(
base64
.
encodestring
(
"ab"
)
==
"YWI=
\
n
"
,
reason
=
"ab encodestring failed"
)
test_support
.
verify
(
base64
.
encodestring
(
"abc"
)
==
"YWJj
\
n
"
,
reason
=
"abc encodestring failed"
)
test_support
.
verify
(
base64
.
encodestring
(
""
)
==
""
,
reason
=
"null encodestring failed"
)
test_support
.
verify
(
base64
.
encodestring
(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#0^&*();:<>,. []{}"
)
==
"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0
\
n
NTY3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==
\
n
"
,
reason
=
"long encodestring failed"
)
def
test_decode_string
(
self
):
"""Testing decode string"""
test_support
.
verify
(
base64
.
decodestring
(
"d3d3LnB5dGhvbi5vcmc=
\
n
"
)
==
"www.python.org"
,
reason
=
"www.python.org decodestring failed"
)
test_support
.
verify
(
base64
.
decodestring
(
"YQ==
\
n
"
)
==
"a"
,
reason
=
"a decodestring failed"
)
test_support
.
verify
(
base64
.
decodestring
(
"YWI=
\
n
"
)
==
"ab"
,
reason
=
"ab decodestring failed"
)
test_support
.
verify
(
base64
.
decodestring
(
"YWJj
\
n
"
)
==
"abc"
,
reason
=
"abc decodestring failed"
)
test_support
.
verify
(
base64
.
decodestring
(
"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0
\
n
NTY3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==
\
n
"
)
==
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#0^&*();:<>,. []{}"
,
reason
=
"long decodestring failed"
)
try
:
base64
.
decodestring
(
""
)
except
binascii_error
:
pass
else
:
self
.
fail
(
"expected a binascii.Error on null decode request"
)
def
test_main
():
test_support
.
run_unittest
(
Base64TestCase
)
if
__name__
==
"__main__"
:
test_main
()
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