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
1341bb00
Kaydet (Commit)
1341bb00
authored
Mar 14, 2011
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closes issue 11407. TestCase.run returns the result object used or created
üst
ba3a978f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
7 deletions
+49
-7
unittest.rst
Doc/library/unittest.rst
+5
-2
case.py
Lib/unittest/case.py
+1
-1
test_case.py
Lib/unittest/test/test_case.py
+39
-4
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/unittest.rst
Dosyayı görüntüle @
1341bb00
...
@@ -723,7 +723,7 @@ Test cases
...
@@ -723,7 +723,7 @@ Test cases
Here, we create two instances of :class:`WidgetTestCase`, each of which runs a
Here, we create two instances of :class:`WidgetTestCase`, each of which runs a
single test.
single test.
.. versionchanged::
.. versionchanged::
3.2
`TestCase` can be instantiated successfully without providing a method
`TestCase` can be instantiated successfully without providing a method
name. This makes it easier to experiment with `TestCase` from the
name. This makes it easier to experiment with `TestCase` from the
interactive interpreter.
interactive interpreter.
...
@@ -792,11 +792,14 @@ Test cases
...
@@ -792,11 +792,14 @@ Test cases
Run the test, collecting the result into the test result object passed as
Run the test, collecting the result into the test result object passed as
*result*. If *result* is omitted or ``None``, a temporary result
*result*. If *result* is omitted or ``None``, a temporary result
object is created (by calling the :meth:`defaultTestResult` method) and
object is created (by calling the :meth:`defaultTestResult` method) and
used. The result object is
not
returned to :meth:`run`'s caller.
used. The result object is returned to :meth:`run`'s caller.
The same effect may be had by simply calling the :class:`TestCase`
The same effect may be had by simply calling the :class:`TestCase`
instance.
instance.
.. versionchanged:: 3.3
Previous versions of ``run`` did not return the result. Neither did
calling an instance.
.. method:: skipTest(reason)
.. method:: skipTest(reason)
...
...
Lib/unittest/case.py
Dosyayı görüntüle @
1341bb00
...
@@ -469,7 +469,7 @@ class TestCase(object):
...
@@ -469,7 +469,7 @@ class TestCase(object):
warnings
.
warn
(
"TestResult has no addExpectedFailure method, reporting as passes"
,
warnings
.
warn
(
"TestResult has no addExpectedFailure method, reporting as passes"
,
RuntimeWarning
)
RuntimeWarning
)
result
.
addSuccess
(
self
)
result
.
addSuccess
(
self
)
return
result
finally
:
finally
:
result
.
stopTest
(
self
)
result
.
stopTest
(
self
)
if
orig_result
is
None
:
if
orig_result
is
None
:
...
...
Lib/unittest/test/test_case.py
Dosyayı görüntüle @
1341bb00
...
@@ -386,27 +386,62 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
...
@@ -386,27 +386,62 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
self
.
assertIsInstance
(
Foo
()
.
id
(),
str
)
self
.
assertIsInstance
(
Foo
()
.
id
(),
str
)
# "If result is omitted or None, a temporary result object is created
# "If result is omitted or None, a temporary result object is created
,
#
and used, but is not
made available to the caller. As TestCase owns the
#
used, and is
made available to the caller. As TestCase owns the
# temporary result startTestRun and stopTestRun are called.
# temporary result startTestRun and stopTestRun are called.
def
test_run__uses_defaultTestResult
(
self
):
def
test_run__uses_defaultTestResult
(
self
):
events
=
[]
events
=
[]
defaultResult
=
LoggingResult
(
events
)
class
Foo
(
unittest
.
TestCase
):
class
Foo
(
unittest
.
TestCase
):
def
test
(
self
):
def
test
(
self
):
events
.
append
(
'test'
)
events
.
append
(
'test'
)
def
defaultTestResult
(
self
):
def
defaultTestResult
(
self
):
return
LoggingResult
(
events
)
return
defaultResult
# Make run() find a result object on its own
# Make run() find a result object on its own
Foo
(
'test'
)
.
run
()
result
=
Foo
(
'test'
)
.
run
()
self
.
assertIs
(
result
,
defaultResult
)
expected
=
[
'startTestRun'
,
'startTest'
,
'test'
,
'addSuccess'
,
expected
=
[
'startTestRun'
,
'startTest'
,
'test'
,
'addSuccess'
,
'stopTest'
,
'stopTestRun'
]
'stopTest'
,
'stopTestRun'
]
self
.
assertEqual
(
events
,
expected
)
self
.
assertEqual
(
events
,
expected
)
# "The result object is returned to run's caller"
def
test_run__returns_given_result
(
self
):
class
Foo
(
unittest
.
TestCase
):
def
test
(
self
):
pass
result
=
unittest
.
TestResult
()
retval
=
Foo
(
'test'
)
.
run
(
result
)
self
.
assertIs
(
retval
,
result
)
# "The same effect [as method run] may be had by simply calling the
# TestCase instance."
def
test_call__invoking_an_instance_delegates_to_run
(
self
):
resultIn
=
unittest
.
TestResult
()
resultOut
=
unittest
.
TestResult
()
class
Foo
(
unittest
.
TestCase
):
def
test
(
self
):
pass
def
run
(
self
,
result
):
self
.
assertIs
(
result
,
resultIn
)
return
resultOut
retval
=
Foo
(
'test'
)(
resultIn
)
self
.
assertIs
(
retval
,
resultOut
)
def
testShortDescriptionWithoutDocstring
(
self
):
def
testShortDescriptionWithoutDocstring
(
self
):
self
.
assertIsNone
(
self
.
shortDescription
())
self
.
assertIsNone
(
self
.
shortDescription
())
...
...
Misc/ACKS
Dosyayı görüntüle @
1341bb00
...
@@ -351,6 +351,7 @@ Lynda Hardman
...
@@ -351,6 +351,7 @@ Lynda Hardman
Derek Harland
Derek Harland
Jason Harper
Jason Harper
Brian Harring
Brian Harring
Jonathan Hartley
Larry Hastings
Larry Hastings
Shane Hathaway
Shane Hathaway
Rycharde Hawkes
Rycharde Hawkes
...
...
Misc/NEWS
Dosyayı görüntüle @
1341bb00
...
@@ -68,6 +68,9 @@ Core and Builtins
...
@@ -68,6 +68,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
11407
:
`
TestCase
.
run
`
returns
the
result
object
used
or
created
.
Contributed
by
Janathan
Hartley
.
-
Issue
#
11500
:
Fixed
a
bug
in
the
os
x
proxy
bypass
code
for
fully
qualified
-
Issue
#
11500
:
Fixed
a
bug
in
the
os
x
proxy
bypass
code
for
fully
qualified
IP
addresses
in
the
proxy
exception
list
.
IP
addresses
in
the
proxy
exception
list
.
...
...
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