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
035a07e2
Kaydet (Commit)
035a07e2
authored
Nis 27, 2000
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add some more contains tests on the builtin types
üst
638ae9d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
test_contains.py
Lib/test/test_contains.py
+47
-0
No files found.
Lib/test/test_contains.py
Dosyayı görüntüle @
035a07e2
...
...
@@ -119,3 +119,50 @@ try:
check
(
0
,
"u'ab' in 'abc' did not raise error"
)
except
TypeError
:
pass
# A collection of tests on builtin sequence types
a
=
range
(
10
)
for
i
in
a
:
check
(
i
in
a
,
"
%
s not in
%
s"
%
(
`i`
,
`a`
))
check
(
16
not
in
a
,
"16 not in
%
s"
%
`a`
)
check
(
a
not
in
a
,
"
%
s not in
%
s"
%
(
`a`
,
`a`
))
a
=
tuple
(
a
)
for
i
in
a
:
check
(
i
in
a
,
"
%
s not in
%
s"
%
(
`i`
,
`a`
))
check
(
16
not
in
a
,
"16 not in
%
s"
%
`a`
)
check
(
a
not
in
a
,
"
%
s not in
%
s"
%
(
`a`
,
`a`
))
class
Deviant1
:
"""Behaves strangely when compared
This class is designed to make sure that the contains code
works when the list is modified during the check.
"""
aLongList
=
range
(
15
)
aShortList
=
range
(
5
)
aList
=
aLongList
def
__cmp__
(
self
,
other
):
if
other
==
12
:
self
.
aList
=
self
.
aShortList
return
1
check
(
Deviant1
()
not
in
Deviant1
.
aList
,
"Deviant1 failed"
)
class
Deviant2
:
"""Behaves strangely when compared
This class raises an exception during comparison. That in
turn causes the comparison to fail with a TypeError.
"""
def
__cmp__
(
self
,
other
):
if
other
==
4
:
raise
RuntimeError
,
"gotcha"
try
:
check
(
Deviant2
()
not
in
a
,
"oops"
)
except
TypeError
:
pass
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