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
d9e50261
Kaydet (Commit)
d9e50261
authored
Mar 07, 2007
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add some sanity checks to unittest.TestSuite's addTest(s) methods.
Fixes #878275.
üst
9decc0dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
test_unittest.py
Lib/test/test_unittest.py
+13
-0
unittest.py
Lib/unittest.py
+9
-0
No files found.
Lib/test/test_unittest.py
Dosyayı görüntüle @
d9e50261
...
...
@@ -1580,6 +1580,19 @@ class Test_TestSuite(TestCase, TestEquality):
pass
else
:
self
.
fail
(
"Failed to raise TypeError"
)
def
test_addTest__noncallable
(
self
):
suite
=
unittest
.
TestSuite
()
self
.
assertRaises
(
TypeError
,
suite
.
addTest
,
5
)
def
test_addTest__casesuiteclass
(
self
):
suite
=
unittest
.
TestSuite
()
self
.
assertRaises
(
TypeError
,
suite
.
addTest
,
Test_TestSuite
)
self
.
assertRaises
(
TypeError
,
suite
.
addTest
,
unittest
.
TestSuite
)
def
test_addTests__string
(
self
):
suite
=
unittest
.
TestSuite
()
self
.
assertRaises
(
TypeError
,
suite
.
addTests
,
"foo"
)
class
Test_FunctionTestCase
(
TestCase
):
...
...
Lib/unittest.py
Dosyayı görüntüle @
d9e50261
...
...
@@ -428,9 +428,18 @@ class TestSuite:
return
cases
def
addTest
(
self
,
test
):
# sanity checks
if
not
callable
(
test
):
raise
TypeError
(
"the test to add must be callable"
)
if
(
isinstance
(
test
,
(
type
,
types
.
ClassType
))
and
issubclass
(
test
,
(
TestCase
,
TestSuite
))):
raise
TypeError
(
"TestCases and TestSuites must be instantiated "
"before passing them to addTest()"
)
self
.
_tests
.
append
(
test
)
def
addTests
(
self
,
tests
):
if
isinstance
(
tests
,
basestring
):
raise
TypeError
(
"tests must be an iterable of tests, not a string"
)
for
test
in
tests
:
self
.
addTest
(
test
)
...
...
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