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
07ef487a
Kaydet (Commit)
07ef487a
authored
May 02, 2009
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
--no commit message
--no commit message
üst
7430989c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
1 deletion
+59
-1
unittest.rst
Doc/library/unittest.rst
+14
-0
2.7.rst
Doc/whatsnew/2.7.rst
+4
-0
test_unittest.py
Lib/test/test_unittest.py
+0
-0
unittest.py
Lib/unittest.py
+30
-1
NEWS
Misc/NEWS
+11
-0
No files found.
Doc/library/unittest.rst
Dosyayı görüntüle @
07ef487a
...
...
@@ -1318,6 +1318,20 @@ Loading and running tests
The default implementation does nothing.
.. method:: startTestRun(test)
Called once before any tests are executed.
.. versionadded:: 2.7
.. method:: stopTestRun(test)
Called once before any tests are executed.
.. versionadded:: 2.7
.. method:: addError(test, err)
Called when the test case *test* raises an unexpected exception *err* is a
...
...
Doc/whatsnew/2.7.rst
Dosyayı görüntüle @
07ef487a
...
...
@@ -517,6 +517,10 @@ changes, or look through the Subversion logs for all the details.
If False ``main`` doesn't call :func:`sys.exit` allowing it to
be used from the interactive interpreter. :issue:`3379`.
:class:`TestResult` has new :meth:`startTestRun` and
:meth:`stopTestRun` methods; called immediately before
and after a test run. :issue:`5728` by Robert Collins.
* The :func:`is_zipfile` function in the :mod:`zipfile` module will now
accept a file object, in addition to the path names accepted in earlier
versions. (Contributed by Gabriel Genellina; :issue:`4756`.)
...
...
Lib/test/test_unittest.py
Dosyayı görüntüle @
07ef487a
This diff is collapsed.
Click to expand it.
Lib/unittest.py
Dosyayı görüntüle @
07ef487a
...
...
@@ -186,10 +186,22 @@ class TestResult(object):
"Called when the given test is about to be run"
self
.
testsRun
=
self
.
testsRun
+
1
def
startTestRun
(
self
):
"""Called once before any tests are executed.
See startTest for a method called before each test.
"""
def
stopTest
(
self
,
test
):
"Called when the given test has been run"
pass
def
stopTestRun
(
self
):
"""Called once after all tests are executed.
See stopTest for a method called after each test.
"""
def
addError
(
self
,
test
,
err
):
"""Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().
...
...
@@ -437,8 +449,13 @@ class TestCase(object):
(
_strclass
(
self
.
__class__
),
self
.
_testMethodName
)
def
run
(
self
,
result
=
None
):
orig_result
=
result
if
result
is
None
:
result
=
self
.
defaultTestResult
()
startTestRun
=
getattr
(
result
,
'startTestRun'
,
None
)
if
startTestRun
is
not
None
:
startTestRun
()
self
.
_result
=
result
result
.
startTest
(
self
)
testMethod
=
getattr
(
self
,
self
.
_testMethodName
)
...
...
@@ -478,6 +495,10 @@ class TestCase(object):
result
.
addSuccess
(
self
)
finally
:
result
.
stopTest
(
self
)
if
orig_result
is
None
:
stopTestRun
=
getattr
(
result
,
'stopTestRun'
,
None
)
if
stopTestRun
is
not
None
:
stopTestRun
()
def
doCleanups
(
self
):
"""Execute all cleanup functions. Normally called for you after
...
...
@@ -1433,7 +1454,15 @@ class TextTestRunner(object):
"Run the given test case or test suite."
result
=
self
.
_makeResult
()
startTime
=
time
.
time
()
test
(
result
)
startTestRun
=
getattr
(
result
,
'startTestRun'
,
None
)
if
startTestRun
is
not
None
:
startTestRun
()
try
:
test
(
result
)
finally
:
stopTestRun
=
getattr
(
result
,
'stopTestRun'
,
None
)
if
stopTestRun
is
not
None
:
stopTestRun
()
stopTime
=
time
.
time
()
timeTaken
=
stopTime
-
startTime
result
.
printErrors
()
...
...
Misc/NEWS
Dosyayı görüntüle @
07ef487a
...
...
@@ -359,6 +359,17 @@ Library
- unittest.assertNotEqual() now uses the inequality operator (!=) instead
of the equality operator.
- Issue #5679: The methods unittest.TestCase.addCleanup and doCleanups were added.
addCleanup allows you to add cleanup functions that will be called
unconditionally (after setUp if setUp fails, otherwise after tearDown). This
allows for much simpler resource allocation and deallocation during tests.
- Issue #3379: unittest.main now takes an optional exit argument. If False main
doesn't call sys.exit allowing it to be used from the interactive interpreter.
- Issue #5728: unittest.TestResult has new startTestRun and stopTestRun methods;
called immediately before and after a test run.
- Issue #5663: better failure messages for unittest asserts. Default assertTrue
and assertFalse messages are now useful. TestCase has a longMessage attribute.
This defaults to False, but if set to True useful error messages are shown in
...
...
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