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
2dc505e0
Kaydet (Commit)
2dc505e0
authored
Ock 15, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
* Add test for __cmp__()
* Add doctest for example in the library reference manual
üst
f60cdff9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
2 deletions
+40
-2
test_sets.py
Lib/test/test_sets.py
+40
-2
No files found.
Lib/test/test_sets.py
Dosyayı görüntüle @
2dc505e0
...
@@ -230,6 +230,10 @@ class TestBinaryOps(unittest.TestCase):
...
@@ -230,6 +230,10 @@ class TestBinaryOps(unittest.TestCase):
result
=
self
.
set
^
Set
([
8
])
result
=
self
.
set
^
Set
([
8
])
self
.
assertEqual
(
result
,
Set
([
2
,
4
,
6
,
8
]))
self
.
assertEqual
(
result
,
Set
([
2
,
4
,
6
,
8
]))
def
test_cmp
(
self
):
a
,
b
=
Set
(
'a'
),
Set
(
'b'
)
self
.
assertRaises
(
TypeError
,
cmp
,
(
a
,
b
))
#==============================================================================
#==============================================================================
class
TestUpdateOps
(
unittest
.
TestCase
):
class
TestUpdateOps
(
unittest
.
TestCase
):
...
@@ -634,6 +638,36 @@ class TestCopyingNested(TestCopying):
...
@@ -634,6 +638,36 @@ class TestCopyingNested(TestCopying):
#==============================================================================
#==============================================================================
libreftest
=
"""
Example from the Library Reference: Doc/lib/libsets.tex
>>> from sets import Set
>>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
>>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
>>> management = Set(['Jane', 'Jack', 'Susan', 'Zack'])
>>> employees = engineers | programmers | management # union
>>> engineering_management = engineers & programmers # intersection
>>> fulltime_management = management - engineers - programmers # difference
>>> engineers.add('Marvin')
>>> print engineers
Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
>>> employees.issuperset(engineers) # superset test
False
>>> employees.update(engineers) # update from another set
>>> employees.issuperset(engineers)
True
>>> for group in [engineers, programmers, management, employees]:
... group.discard('Susan') # unconditionally remove element
... print group
...
Set(['Jane', 'Marvin', 'Janice', 'John', 'Jack'])
Set(['Janice', 'Jack', 'Sam'])
Set(['Jane', 'Zack', 'Jack'])
Set(['Zack', 'Sam', 'Marvin', 'Jack', 'Jane', 'Janice', 'John'])
"""
#==============================================================================
def
makeAllTests
():
def
makeAllTests
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
for
klass
in
(
TestSetOfSets
,
for
klass
in
(
TestSetOfSets
,
...
@@ -664,9 +698,13 @@ def makeAllTests():
...
@@ -664,9 +698,13 @@ def makeAllTests():
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
def
test_main
():
__test__
=
{
'libreftest'
:
libreftest
}
def
test_main
(
verbose
=
None
):
from
test
import
test_sets
suite
=
makeAllTests
()
suite
=
makeAllTests
()
test_support
.
run_suite
(
suite
)
test_support
.
run_suite
(
suite
)
test_support
.
run_doctest
(
test_sets
,
verbose
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_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