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
97656a1c
Commit
97656a1c
authored
May 18, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simple conversion to PyUnit.
parent
5b811bee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
Lib/test/test_hash.py
Lib/test/test_hash.py
+19
-11
No files found.
Lib/test/test_hash.py
View file @
97656a1c
...
...
@@ -3,21 +3,29 @@
#
import
test_support
import
unittest
def
same_hash
(
*
objlist
):
class
HashEqualityTestCase
(
unittest
.
TestCase
):
def
same_hash
(
self
,
*
objlist
):
# hash each object given an raise TestFailed if
# the hash values are not all the same
hashed
=
map
(
hash
,
objlist
)
for
h
in
hashed
[
1
:]:
if
h
!=
hashed
[
0
]:
raise
TestFailed
,
"hashed values differ: %s"
%
`objlist`
self
.
fail
(
"hashed values differ: %s"
%
`objlist`
)
def
test_numeric_literals
(
self
):
self
.
same_hash
(
1
,
1L
,
1.0
,
1.0
+
0.0j
)
def
test_coerced_integers
(
self
):
self
.
same_hash
(
int
(
1
),
long
(
1
),
float
(
1
),
complex
(
1
),
int
(
'1'
),
float
(
'1.0'
))
same_hash
(
1
,
1L
,
1.0
,
1.0
+
0.0j
)
same_hash
(
int
(
1
),
long
(
1
),
float
(
1
),
complex
(
1
))
def
test_coerced_floats
(
self
):
self
.
same_hash
(
long
(
1.23e300
),
float
(
1.23e300
))
self
.
same_hash
(
float
(
0.5
),
complex
(
0.5
,
0.0
))
same_hash
(
long
(
1.23e300
),
float
(
1.23e300
))
same_hash
(
float
(
0.5
),
complex
(
0.5
,
0.0
)
)
test_support
.
run_unittest
(
HashEqualityTestCase
)
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