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
b5c66f86
Kaydet (Commit)
b5c66f86
authored
Ara 28, 2013
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix breakage in TestSuite.countTestCases() introduced by issue #11798.
üst
156b3610
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
4 deletions
+45
-4
suite.py
Lib/unittest/suite.py
+12
-4
test_suite.py
Lib/unittest/test/test_suite.py
+31
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/unittest/suite.py
Dosyayı görüntüle @
b5c66f86
...
...
@@ -20,6 +20,7 @@ class BaseTestSuite(object):
def
__init__
(
self
,
tests
=
()):
self
.
_tests
=
[]
self
.
_removed_tests
=
0
self
.
addTests
(
tests
)
def
__repr__
(
self
):
...
...
@@ -37,9 +38,10 @@ class BaseTestSuite(object):
return
iter
(
self
.
_tests
)
def
countTestCases
(
self
):
cases
=
0
cases
=
self
.
_removed_tests
for
test
in
self
:
cases
+=
test
.
countTestCases
()
if
test
:
cases
+=
test
.
countTestCases
()
return
cases
def
addTest
(
self
,
test
):
...
...
@@ -70,10 +72,16 @@ class BaseTestSuite(object):
def
_removeTestAtIndex
(
self
,
index
):
"""Stop holding a reference to the TestCase at index."""
try
:
self
.
_tests
[
index
]
=
None
test
=
self
.
_tests
[
index
]
except
TypeError
:
# support for suite implementations that have overriden self._test
# support for suite implementations that have overriden self._test
s
pass
else
:
# Some unittest tests add non TestCase/TestSuite objects to
# the suite.
if
hasattr
(
test
,
'countTestCases'
):
self
.
_removed_tests
+=
test
.
countTestCases
()
self
.
_tests
[
index
]
=
None
def
__call__
(
self
,
*
args
,
**
kwds
):
return
self
.
run
(
*
args
,
**
kwds
)
...
...
Lib/unittest/test/test_suite.py
Dosyayı görüntüle @
b5c66f86
...
...
@@ -51,6 +51,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite
=
unittest
.
TestSuite
()
self
.
assertEqual
(
suite
.
countTestCases
(),
0
)
# countTestCases() still works after tests are run
suite
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite
.
countTestCases
(),
0
)
# "class TestSuite([tests])"
# ...
...
...
@@ -63,6 +66,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite
=
unittest
.
TestSuite
([])
self
.
assertEqual
(
suite
.
countTestCases
(),
0
)
# countTestCases() still works after tests are run
suite
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite
.
countTestCases
(),
0
)
# "class TestSuite([tests])"
# ...
...
...
@@ -84,6 +90,14 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite_3
=
unittest
.
TestSuite
(
set
(
suite_1
))
self
.
assertEqual
(
suite_3
.
countTestCases
(),
2
)
# countTestCases() still works after tests are run
suite_1
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite_1
.
countTestCases
(),
2
)
suite_2
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite_2
.
countTestCases
(),
2
)
suite_3
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite_3
.
countTestCases
(),
2
)
# "class TestSuite([tests])"
# ...
# "If tests is given, it must be an iterable of individual test cases
...
...
@@ -99,6 +113,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite
=
unittest
.
TestSuite
(
tests
())
self
.
assertEqual
(
suite
.
countTestCases
(),
2
)
# countTestCases() still works after tests are run
suite
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite
.
countTestCases
(),
2
)
################################################################
### /Tests for TestSuite.__init__
...
...
@@ -145,6 +162,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
suite
=
unittest
.
TestSuite
((
test1
,
test2
))
self
.
assertEqual
(
suite
.
countTestCases
(),
2
)
# countTestCases() still works after tests are run
suite
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite
.
countTestCases
(),
2
)
# "Return the number of tests represented by the this test object.
# ...this method is also implemented by the TestSuite class, which can
...
...
@@ -162,6 +182,10 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
parent
=
unittest
.
TestSuite
((
test3
,
child
,
Test1
(
'test1'
)))
self
.
assertEqual
(
parent
.
countTestCases
(),
4
)
# countTestCases() still works after tests are run
parent
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
parent
.
countTestCases
(),
4
)
self
.
assertEqual
(
child
.
countTestCases
(),
2
)
# "Run the tests associated with this suite, collecting the result into
# the test result object passed as result."
...
...
@@ -220,6 +244,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self
.
assertEqual
(
suite
.
countTestCases
(),
1
)
self
.
assertEqual
(
list
(
suite
),
[
test
])
# countTestCases() still works after tests are run
suite
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite
.
countTestCases
(),
1
)
# "Add a ... TestSuite to the suite"
def
test_addTest__TestSuite
(
self
):
...
...
@@ -233,6 +260,9 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self
.
assertEqual
(
suite
.
countTestCases
(),
1
)
self
.
assertEqual
(
list
(
suite
),
[
suite_2
])
# countTestCases() still works after tests are run
suite
.
run
(
unittest
.
TestResult
())
self
.
assertEqual
(
suite
.
countTestCases
(),
1
)
# "Add all the tests from an iterable of TestCase and TestSuite
# instances to this test suite."
...
...
@@ -392,6 +422,7 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self
.
assertEqual
(
len
(
result
.
errors
),
1
)
self
.
assertEqual
(
len
(
result
.
failures
),
0
)
self
.
assertEqual
(
result
.
testsRun
,
2
)
self
.
assertEqual
(
suite
.
countTestCases
(),
2
)
def
test_overriding_call
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
b5c66f86
...
...
@@ -44,6 +44,8 @@ Core and Builtins
Library
-------
- Fix breakage in TestSuite.countTestCases() introduced by issue #11798.
- Issue #19918: Fix PurePath.relative_to() under Windows.
- Issue #19422: Explicitly disallow non-SOCK_STREAM sockets in the ssl
...
...
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