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
2312024e
Commit
2312024e
authored
Jan 18, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test that ensures hash() of objects defining __cmp__ or __eq__ but
not __hash__ raises TypeError.
parent
65e8bd7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
Lib/test/test_class.py
Lib/test/test_class.py
+23
-0
No files found.
Lib/test/test_class.py
View file @
2312024e
"Test the functionality of Python classes implementing operators."
from
test_support
import
TestFailed
testmeths
=
[
...
...
@@ -216,3 +217,25 @@ testme = ExtraTests()
testme
.
spam
testme
.
eggs
=
"spam, spam, spam and ham"
del
testme
.
cardinal
# Test correct errors from hash() on objects with comparisons but no __hash__
class
C0
:
pass
hash
(
C0
())
# This should work; the next two should raise TypeError
class
C1
:
def
__cmp__
(
self
,
other
):
return
0
try
:
hash
(
C1
())
except
TypeError
:
pass
else
:
raise
TestFailed
,
"hash(C1()) should raise an exception"
class
C2
:
def
__eq__
(
self
,
other
):
return
1
try
:
hash
(
C2
())
except
TypeError
:
pass
else
:
raise
TestFailed
,
"hash(C2()) should raise an exception"
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