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
e29a1030
Commit
e29a1030
authored
Jun 11, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for heapq using both __lt__ and __le__.
parent
a809c98c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
Lib/test/test_heapq.py
Lib/test/test_heapq.py
+21
-0
No files found.
Lib/test/test_heapq.py
View file @
e29a1030
...
@@ -196,6 +196,27 @@ class TestHeapPython(TestHeap):
...
@@ -196,6 +196,27 @@ class TestHeapPython(TestHeap):
class
TestHeapC
(
TestHeap
):
class
TestHeapC
(
TestHeap
):
module
=
c_heapq
module
=
c_heapq
def
test_comparison_operator
(
self
):
# Issue 3501: Make sure heapq works with both __lt__ and __le__
def
hsort
(
data
,
comp
):
data
=
map
(
comp
,
data
)
self
.
module
.
heapify
(
data
)
return
[
self
.
module
.
heappop
(
data
).
x
for
i
in
range
(
len
(
data
))]
class
LT
:
def
__init__
(
self
,
x
):
self
.
x
=
x
def
__lt__
(
self
,
other
):
return
self
.
x
>
other
.
x
class
LE
:
def
__init__
(
self
,
x
):
self
.
x
=
x
def
__lt__
(
self
,
other
):
return
self
.
x
>=
other
.
x
data
=
[
random
.
random
()
for
i
in
range
(
100
)]
target
=
sorted
(
data
,
reverse
=
True
)
self
.
assertEqual
(
hsort
(
data
,
LT
),
target
)
self
.
assertEqual
(
hsort
(
data
,
LE
),
target
)
#==============================================================================
#==============================================================================
...
...
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