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
63251781
Kaydet (Commit)
63251781
authored
Eyl 27, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Beef-up tests for greater coverage and refcount checking.
üst
b6aa856f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
1 deletion
+59
-1
test_bisect.py
Lib/test/test_bisect.py
+59
-1
No files found.
Lib/test/test_bisect.py
Dosyayı görüntüle @
63251781
...
...
@@ -151,6 +151,47 @@ class TestInsort(unittest.TestCase):
#==============================================================================
class
LenOnly
:
"Dummy sequence class defining __len__ but not __getitem__."
def
__len__
(
self
):
return
10
class
GetOnly
:
"Dummy sequence class defining __getitem__ but not __len__."
def
__getitem__
(
self
,
ndx
):
return
10
class
CmpErr
:
"Dummy element that always raises an error during comparison"
def
__cmp__
(
self
,
other
):
raise
ZeroDivisionError
class
TestErrorHandling
(
unittest
.
TestCase
):
def
test_non_sequence
(
self
):
for
f
in
(
bisect_left
,
bisect_right
,
insort_left
,
insort_right
):
self
.
assertRaises
(
TypeError
,
f
,
10
,
10
)
def
test_len_only
(
self
):
for
f
in
(
bisect_left
,
bisect_right
,
insort_left
,
insort_right
):
self
.
assertRaises
(
AttributeError
,
f
,
LenOnly
(),
10
)
def
test_get_only
(
self
):
for
f
in
(
bisect_left
,
bisect_right
,
insort_left
,
insort_right
):
self
.
assertRaises
(
AttributeError
,
f
,
GetOnly
(),
10
)
def
test_get_only
(
self
):
seq
=
[
CmpErr
(),
CmpErr
(),
CmpErr
()]
for
f
in
(
bisect_left
,
bisect_right
,
insort_left
,
insort_right
):
self
.
assertRaises
(
ZeroDivisionError
,
f
,
seq
,
10
)
def
test_arg_parsing
(
self
):
for
f
in
(
bisect_left
,
bisect_right
,
insort_left
,
insort_right
):
self
.
assertRaises
(
TypeError
,
f
,
10
)
#==============================================================================
libreftest
=
"""
Example from the Library Reference: Doc/lib/libbisect.tex
...
...
@@ -178,8 +219,25 @@ __test__ = {'libreftest' : libreftest}
def
test_main
(
verbose
=
None
):
from
test
import
test_bisect
test_support
.
run_unittest
(
TestBisect
,
TestInsort
)
from
types
import
BuiltinFunctionType
import
sys
test_classes
=
[
TestBisect
,
TestInsort
]
if
isinstance
(
bisect_left
,
BuiltinFunctionType
):
test_classes
.
append
(
TestErrorHandling
)
test_support
.
run_unittest
(
*
test_classes
)
test_support
.
run_doctest
(
test_bisect
,
verbose
)
# verify reference counting
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
import
gc
counts
=
[
None
]
*
5
for
i
in
xrange
(
len
(
counts
)):
test_support
.
run_unittest
(
*
test_classes
)
gc
.
collect
()
counts
[
i
]
=
sys
.
gettotalrefcount
()
print
counts
if
__name__
==
"__main__"
:
test_main
(
verbose
=
True
)
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