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
93d8d48c
Kaydet (Commit)
93d8d48c
authored
Agu 25, 2002
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
TestSubset(): Generalized the framework to support testing upcoming
<, <=, etc methods too.
üst
4127e91d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
test_sets.py
Lib/test/test_sets.py
+23
-10
No files found.
Lib/test/test_sets.py
Dosyayı görüntüle @
93d8d48c
...
...
@@ -361,12 +361,25 @@ class TestMutate(unittest.TestCase):
class
TestSubsets
(
unittest
.
TestCase
):
case2method
=
{
"<="
:
"issubset"
,
">="
:
"issuperset"
,
}
cases_with_ops
=
Set
([
"=="
,
"!="
])
def
test_issubset
(
self
):
result
=
self
.
left
.
issubset
(
self
.
right
)
if
"<"
in
self
.
cases
:
self
.
failUnless
(
result
)
else
:
self
.
failUnless
(
not
result
)
x
=
self
.
left
y
=
self
.
right
for
case
in
"!="
,
"=="
,
"<"
,
"<="
,
">"
,
">="
:
expected
=
case
in
self
.
cases
if
case
in
TestSubsets
.
case2method
:
# Test the method-name spelling.
method
=
getattr
(
x
,
TestSubsets
.
case2method
[
case
])
result
=
method
(
y
)
self
.
assertEqual
(
result
,
expected
)
if
case
in
TestSubsets
.
cases_with_ops
:
# Test the binary infix spelling.
result
=
eval
(
"x"
+
case
+
"y"
,
locals
())
self
.
assertEqual
(
result
,
expected
)
#------------------------------------------------------------------------------
...
...
@@ -374,7 +387,7 @@ class TestSubsetEqualEmpty(TestSubsets):
left
=
Set
()
right
=
Set
()
name
=
"both empty"
cases
=
"
<>
"
cases
=
"
=="
,
"<="
,
">=
"
#------------------------------------------------------------------------------
...
...
@@ -382,7 +395,7 @@ class TestSubsetEqualNonEmpty(TestSubsets):
left
=
Set
([
1
,
2
])
right
=
Set
([
1
,
2
])
name
=
"equal pair"
cases
=
"
<>
"
cases
=
"
=="
,
"<="
,
">=
"
#------------------------------------------------------------------------------
...
...
@@ -390,7 +403,7 @@ class TestSubsetEmptyNonEmpty(TestSubsets):
left
=
Set
()
right
=
Set
([
1
,
2
])
name
=
"one empty, one non-empty"
cases
=
"
<
"
cases
=
"
!="
,
"<"
,
"<=
"
#------------------------------------------------------------------------------
...
...
@@ -398,7 +411,7 @@ class TestSubsetPartial(TestSubsets):
left
=
Set
([
1
])
right
=
Set
([
1
,
2
])
name
=
"one a non-empty subset of other"
cases
=
"
<
"
cases
=
"
!="
,
"<"
,
"<=
"
#------------------------------------------------------------------------------
...
...
@@ -406,7 +419,7 @@ class TestSubsetNonOverlap(TestSubsets):
left
=
Set
([
1
])
right
=
Set
([
2
])
name
=
"neither empty, neither contains"
cases
=
""
cases
=
"
!=
"
#==============================================================================
...
...
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