Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
grumpy
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
grumpy
Commits
9fc5bd88
Commit
9fc5bd88
authored
Jan 27, 2017
by
YOU
Committed by
Dylan Trotter
Jan 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use stdlib unittest for md5 instead of custom one (#222)
parent
32103ccb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
18 deletions
+64
-18
Makefile
Makefile
+1
-0
testing/md5_test.py
testing/md5_test.py
+0
-18
third_party/stdlib/test/test_md5.py
third_party/stdlib/test/test_md5.py
+63
-0
No files found.
Makefile
View file @
9fc5bd88
...
...
@@ -92,6 +92,7 @@ STDLIB_TESTS := \
test
/test_list
\
test
/test_slice
\
test
/test_string
\
test
/test_md5
\
threading_test
\
time_test
\
types_test
\
...
...
testing/md5_test.py
deleted
100644 → 0
View file @
32103ccb
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
md5
assert
md5
.
new
(
""
).
hexdigest
()
==
'd41d8cd98f00b204e9800998ecf8427e'
assert
md5
.
new
(
"hello"
).
hexdigest
()
==
'5d41402abc4b2a76b9719d911017c592'
third_party/stdlib/test/test_md5.py
0 → 100644
View file @
9fc5bd88
# Testing md5 module
import
warnings
warnings
.
filterwarnings
(
"ignore"
,
"the md5 module is deprecated.*"
,
DeprecationWarning
)
import
unittest
# from md5 import md5
import
md5
as
_md5
md5
=
_md5
.
md5
from
test
import
test_support
def
hexstr
(
s
):
import
string
h
=
string
.
hexdigits
r
=
''
for
c
in
s
:
i
=
ord
(
c
)
r
=
r
+
h
[(
i
>>
4
)
&
0xF
]
+
h
[
i
&
0xF
]
return
r
class
MD5_Test
(
unittest
.
TestCase
):
def
md5test
(
self
,
s
,
expected
):
self
.
assertEqual
(
hexstr
(
md5
(
s
).
digest
()),
expected
)
self
.
assertEqual
(
md5
(
s
).
hexdigest
(),
expected
)
def
test_basics
(
self
):
eq
=
self
.
md5test
eq
(
''
,
'd41d8cd98f00b204e9800998ecf8427e'
)
eq
(
'a'
,
'0cc175b9c0f1b6a831c399e269772661'
)
eq
(
'abc'
,
'900150983cd24fb0d6963f7d28e17f72'
)
eq
(
'message digest'
,
'f96b697d7cb7938d525a2f31aaf161d0'
)
eq
(
'abcdefghijklmnopqrstuvwxyz'
,
'c3fcd3d76192e4007dfb496cca67e13b'
)
eq
(
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
,
'd174ab98d277d9f5a5611c2c9f419d9f'
)
eq
(
'12345678901234567890123456789012345678901234567890123456789012345678901234567890'
,
'57edf4a22be3c955ac49da2e2107b67a'
)
def
test_hexdigest
(
self
):
# hexdigest is new with Python 2.0
m
=
md5
(
'testing the hexdigest method'
)
h
=
m
.
hexdigest
()
self
.
assertEqual
(
hexstr
(
m
.
digest
()),
h
)
def
test_large_update
(
self
):
aas
=
'a'
*
64
bees
=
'b'
*
64
cees
=
'c'
*
64
m1
=
md5
()
m1
.
update
(
aas
)
m1
.
update
(
bees
)
m1
.
update
(
cees
)
m2
=
md5
()
m2
.
update
(
aas
+
bees
+
cees
)
self
.
assertEqual
(
m1
.
digest
(),
m2
.
digest
())
def
test_main
():
test_support
.
run_unittest
(
MD5_Test
)
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