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
be3c2fea
Commit
be3c2fea
authored
Nov 13, 2013
by
Ethan Furman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed Enum.__eq__ as it added nothing
parent
82e9f32f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
Lib/enum.py
Lib/enum.py
+0
-5
Lib/test/test_enum.py
Lib/test/test_enum.py
+11
-0
No files found.
Lib/enum.py
View file @
be3c2fea
...
...
@@ -447,11 +447,6 @@ class Enum(metaclass=EnumMeta):
return
([
'__class__'
,
'__doc__'
,
'__module__'
,
'name'
,
'value'
]
+
added_behavior
)
def
__eq__
(
self
,
other
):
if
type
(
other
)
is
self
.
__class__
:
return
self
is
other
return
NotImplemented
def
__format__
(
self
,
format_spec
):
# mixed-in Enums should use the mixed-in type's __format__, otherwise
# we can get strange results with the Enum name showing up instead of
...
...
Lib/test/test_enum.py
View file @
be3c2fea
...
...
@@ -1030,6 +1030,15 @@ class TestEnum(unittest.TestCase):
self
.
assertEqual
(
list
(
Color
),
[
Color
.
red
,
Color
.
green
,
Color
.
blue
])
self
.
assertEqual
(
list
(
map
(
int
,
Color
)),
[
1
,
2
,
3
])
def
test_equality
(
self
):
class
AlwaysEqual
:
def
__eq__
(
self
,
other
):
return
True
class
OrdinaryEnum
(
Enum
):
a
=
1
self
.
assertEqual
(
AlwaysEqual
(),
OrdinaryEnum
.
a
)
self
.
assertEqual
(
OrdinaryEnum
.
a
,
AlwaysEqual
())
def
test_ordered_mixin
(
self
):
class
OrderedEnum
(
Enum
):
def
__ge__
(
self
,
other
):
...
...
@@ -1058,6 +1067,8 @@ class TestEnum(unittest.TestCase):
self
.
assertLessEqual
(
Grade
.
F
,
Grade
.
C
)
self
.
assertLess
(
Grade
.
D
,
Grade
.
A
)
self
.
assertGreaterEqual
(
Grade
.
B
,
Grade
.
B
)
self
.
assertEqual
(
Grade
.
B
,
Grade
.
B
)
self
.
assertNotEqual
(
Grade
.
C
,
Grade
.
D
)
def
test_extending2
(
self
):
class
Shade
(
Enum
):
...
...
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