Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
19f7ca25
Kaydet (Commit)
19f7ca25
authored
May 09, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
#11910: merge with 3.1.
üst
fd69abb3
8269a44d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
test_heapq.py
Lib/test/test_heapq.py
+29
-15
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_heapq.py
Dosyayı görüntüle @
19f7ca25
"""Unittests for heapq."""
import
sys
import
random
import
unittest
from
test
import
support
import
sy
s
from
unittest
import
TestCase
,
skipUnles
s
# We do a bit of trickery here to be able to test both the C implementation
# and the Python implementation of the module.
import
heapq
as
c_heapq
py_heapq
=
support
.
import_fresh_module
(
'heapq'
,
blocked
=
[
'_heapq'
])
c_heapq
=
support
.
import_fresh_module
(
'heapq'
,
fresh
=
[
'_heapq'
])
# _heapq.nlargest/nsmallest are saved in heapq._nlargest/_smallest when
# _heapq is imported, so check them there
func_names
=
[
'heapify'
,
'heappop'
,
'heappush'
,
'heappushpop'
,
'heapreplace'
,
'_nlargest'
,
'_nsmallest'
]
class
TestModules
(
TestCase
):
def
test_py_functions
(
self
):
for
fname
in
func_names
:
self
.
assertEqual
(
getattr
(
py_heapq
,
fname
)
.
__module__
,
'heapq'
)
@skipUnless
(
c_heapq
,
'requires _heapq'
)
def
test_c_functions
(
self
):
for
fname
in
func_names
:
self
.
assertEqual
(
getattr
(
c_heapq
,
fname
)
.
__module__
,
'_heapq'
)
class
TestHeap
(
unittest
.
TestCase
):
class
TestHeap
(
TestCase
):
module
=
None
def
test_push_pop
(
self
):
...
...
@@ -176,16 +191,12 @@ class TestHeap(unittest.TestCase):
self
.
assertEqual
(
list
(
self
.
module
.
nlargest
(
n
,
data
,
key
=
f
)),
sorted
(
data
,
key
=
f
,
reverse
=
True
)[:
n
])
class
TestHeapPython
(
TestHeap
):
module
=
py_heapq
# As an early adopter, we sanity check the
# test.support.import_fresh_module utility function
def
test_pure_python
(
self
):
self
.
assertFalse
(
sys
.
modules
[
'heapq'
]
is
self
.
module
)
self
.
assertTrue
(
hasattr
(
self
.
module
.
heapify
,
'__code__'
))
@skipUnless
(
c_heapq
,
'requires _heapq'
)
class
TestHeapC
(
TestHeap
):
module
=
c_heapq
...
...
@@ -307,7 +318,8 @@ def L(seqn):
'Test multiple tiers of iterators'
return
chain
(
map
(
lambda
x
:
x
,
R
(
Ig
(
G
(
seqn
)))))
class
TestErrorHandling
(
unittest
.
TestCase
):
class
TestErrorHandling
(
TestCase
):
module
=
None
def
test_non_sequence
(
self
):
...
...
@@ -358,9 +370,11 @@ class TestErrorHandling(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
f
,
2
,
N
(
s
))
self
.
assertRaises
(
ZeroDivisionError
,
f
,
2
,
E
(
s
))
class
TestErrorHandlingPython
(
TestErrorHandling
):
module
=
py_heapq
@skipUnless
(
c_heapq
,
'requires _heapq'
)
class
TestErrorHandlingC
(
TestErrorHandling
):
module
=
c_heapq
...
...
@@ -369,8 +383,8 @@ class TestErrorHandlingC(TestErrorHandling):
def
test_main
(
verbose
=
None
):
test_classes
=
[
Test
HeapPython
,
TestHeapC
,
TestErrorHandlingPython
,
TestErrorHandlingC
]
test_classes
=
[
Test
Modules
,
TestHeapPython
,
TestHeapC
,
TestErrorHandling
Python
,
TestErrorHandling
C
]
support
.
run_unittest
(
*
test_classes
)
# verify reference counting
...
...
Misc/NEWS
Dosyayı görüntüle @
19f7ca25
...
...
@@ -826,6 +826,8 @@ Tools/Demos
Tests
-----
- Issue #11910: Fix test_heapq to skip the C tests when _heapq is missing.
- Fix test_startfile to wait for child process to terminate before finishing.
- Issue #10822: Fix test_posix:test_getgroups failure under Solaris. Patch
...
...
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