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
f895cf5d
Kaydet (Commit)
f895cf5d
authored
Eki 01, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#7031: Add TestCase.assertIsInstance and negated method.
üst
46cc46af
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
unittest.rst
Doc/library/unittest.rst
+16
-0
test_unittest.py
Lib/test/test_unittest.py
+12
-0
case.py
Lib/unittest/case.py
+13
-0
No files found.
Doc/library/unittest.rst
Dosyayı görüntüle @
f895cf5d
...
...
@@ -955,6 +955,22 @@ Test cases
.. versionadded:: 2.7
.. method:: assertIsInstance(obj, cls[, msg])
This signals a test failure if *obj* is not an instance of *cls* (which
can be a class or a tuple of classes, as supported by :func:`isinstance`).
.. versionadded:: 2.7
.. method:: assertNotIsInstance(obj, cls[, msg])
The inverse of the :meth:`assertIsInstance` method. This signals a test
failure if *obj* is an instance of *cls*.
.. versionadded:: 2.7
.. method:: assertFalse(expr[, msg])
failIf(expr[, msg])
...
...
Lib/test/test_unittest.py
Dosyayı görüntüle @
f895cf5d
...
...
@@ -2500,6 +2500,18 @@ class Test_TestCase(TestCase, TestEquality, TestHashing):
self
.
assertIsNot
(
thing
,
object
())
self
.
assertRaises
(
self
.
failureException
,
self
.
assertIsNot
,
thing
,
thing
)
def
testAssertIsInstance
(
self
):
thing
=
[]
self
.
assertIsInstance
(
thing
,
list
)
self
.
assertRaises
(
self
.
failureException
,
self
.
assertIsInstance
,
thing
,
dict
)
def
testAssertNotIsInstance
(
self
):
thing
=
[]
self
.
assertNotIsInstance
(
thing
,
dict
)
self
.
assertRaises
(
self
.
failureException
,
self
.
assertNotIsInstance
,
thing
,
list
)
def
testAssertIn
(
self
):
animals
=
{
'monkey'
:
'banana'
,
'cow'
:
'grass'
,
'seal'
:
'fish'
}
...
...
Lib/unittest/case.py
Dosyayı görüntüle @
f895cf5d
...
...
@@ -817,6 +817,19 @@ class TestCase(object):
standardMsg
=
'unexpectedly None'
self
.
fail
(
self
.
_formatMessage
(
msg
,
standardMsg
))
def
assertIsInstance
(
self
,
obj
,
cls
,
msg
=
None
):
"""Same as self.assertTrue(isinstance(obj, cls)), with a nicer
default message."""
if
not
isinstance
(
obj
,
cls
):
standardMsg
=
'
%
r is not an instance of
%
r'
%
(
obj
,
cls
)
self
.
fail
(
self
.
_formatMessage
(
msg
,
standardMsg
))
def
assertNotIsInstance
(
self
,
obj
,
cls
,
msg
=
None
):
"""Included for symmetry with assertIsInstance."""
if
isinstance
(
obj
,
cls
):
standardMsg
=
'
%
r is an instance of
%
r'
%
(
obj
,
cls
)
self
.
fail
(
self
.
_formatMessage
(
msg
,
standardMsg
))
def
assertRaisesRegexp
(
self
,
expected_exception
,
expected_regexp
,
callable_obj
=
None
,
*
args
,
**
kwargs
):
"""Asserts that the message in a raised exception matches a regexp.
...
...
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