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
bc398690
Kaydet (Commit)
bc398690
authored
Kas 16, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #19594: Use specific asserts in unittest tests.
üst
8f203dda
5665bc59
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
28 deletions
+28
-28
test_case.py
Lib/unittest/test/test_case.py
+6
-6
test_loader.py
Lib/unittest/test/test_loader.py
+1
-1
test_result.py
Lib/unittest/test/test_result.py
+2
-2
testhelpers.py
Lib/unittest/test/testmock/testhelpers.py
+9
-9
testmagicmethods.py
Lib/unittest/test/testmock/testmagicmethods.py
+4
-4
testmock.py
Lib/unittest/test/testmock/testmock.py
+5
-5
testsentinel.py
Lib/unittest/test/testmock/testsentinel.py
+1
-1
No files found.
Lib/unittest/test/test_case.py
Dosyayı görüntüle @
bc398690
...
...
@@ -407,7 +407,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
def
test
(
self
):
pass
self
.
assert
True
(
Foo
(
'test'
)
.
failureException
is
AssertionError
)
self
.
assert
Is
(
Foo
(
'test'
)
.
failureException
,
AssertionError
)
# "This class attribute gives the exception raised by the test() method.
# If a test framework needs to use a specialized exception, possibly to
...
...
@@ -425,7 +425,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
failureException
=
RuntimeError
self
.
assert
True
(
Foo
(
'test'
)
.
failureException
is
RuntimeError
)
self
.
assert
Is
(
Foo
(
'test'
)
.
failureException
,
RuntimeError
)
Foo
(
'test'
)
.
run
(
result
)
...
...
@@ -448,7 +448,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
failureException
=
RuntimeError
self
.
assert
True
(
Foo
(
'test'
)
.
failureException
is
RuntimeError
)
self
.
assert
Is
(
Foo
(
'test'
)
.
failureException
,
RuntimeError
)
Foo
(
'test'
)
.
run
(
result
)
...
...
@@ -760,7 +760,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
msg
=
e
.
args
[
0
]
else
:
self
.
fail
(
'assertSequenceEqual did not fail.'
)
self
.
assert
True
(
len
(
msg
)
<
len
(
diff
))
self
.
assert
Less
(
len
(
msg
),
len
(
diff
))
self
.
assertIn
(
omitted
,
msg
)
self
.
maxDiff
=
len
(
diff
)
*
2
...
...
@@ -770,7 +770,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
msg
=
e
.
args
[
0
]
else
:
self
.
fail
(
'assertSequenceEqual did not fail.'
)
self
.
assert
True
(
len
(
msg
)
>
len
(
diff
))
self
.
assert
Greater
(
len
(
msg
),
len
(
diff
))
self
.
assertNotIn
(
omitted
,
msg
)
self
.
maxDiff
=
None
...
...
@@ -780,7 +780,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
msg
=
e
.
args
[
0
]
else
:
self
.
fail
(
'assertSequenceEqual did not fail.'
)
self
.
assert
True
(
len
(
msg
)
>
len
(
diff
))
self
.
assert
Greater
(
len
(
msg
),
len
(
diff
))
self
.
assertNotIn
(
omitted
,
msg
)
def
testTruncateMessage
(
self
):
...
...
Lib/unittest/test/test_loader.py
Dosyayı görüntüle @
bc398690
...
...
@@ -1305,7 +1305,7 @@ class Test_TestLoader(unittest.TestCase):
# "The default value is the TestSuite class"
def
test_suiteClass__default_value
(
self
):
loader
=
unittest
.
TestLoader
()
self
.
assert
True
(
loader
.
suiteClass
is
unittest
.
TestSuite
)
self
.
assert
Is
(
loader
.
suiteClass
,
unittest
.
TestSuite
)
if
__name__
==
"__main__"
:
...
...
Lib/unittest/test/test_result.py
Dosyayı görüntüle @
bc398690
...
...
@@ -176,7 +176,7 @@ class Test_TestResult(unittest.TestCase):
self
.
assertEqual
(
result
.
shouldStop
,
False
)
test_case
,
formatted_exc
=
result
.
failures
[
0
]
self
.
assert
True
(
test_case
is
test
)
self
.
assert
Is
(
test_case
,
test
)
self
.
assertIsInstance
(
formatted_exc
,
str
)
# "addError(test, err)"
...
...
@@ -224,7 +224,7 @@ class Test_TestResult(unittest.TestCase):
self
.
assertEqual
(
result
.
shouldStop
,
False
)
test_case
,
formatted_exc
=
result
.
errors
[
0
]
self
.
assert
True
(
test_case
is
test
)
self
.
assert
Is
(
test_case
,
test
)
self
.
assertIsInstance
(
formatted_exc
,
str
)
def
test_addSubTest
(
self
):
...
...
Lib/unittest/test/testmock/testhelpers.py
Dosyayı görüntüle @
bc398690
...
...
@@ -177,7 +177,7 @@ class CallTest(unittest.TestCase):
args
=
_Call
(((
1
,
2
,
3
),
{}))
self
.
assertEqual
(
args
,
call
(
1
,
2
,
3
))
self
.
assertEqual
(
call
(
1
,
2
,
3
),
args
)
self
.
assert
True
(
call
(
1
,
2
,
3
)
in
[
args
])
self
.
assert
In
(
call
(
1
,
2
,
3
),
[
args
])
def
test_call_ne
(
self
):
...
...
@@ -812,7 +812,7 @@ class SpecSignatureTest(unittest.TestCase):
mock_property
=
foo
.
foo
# no spec on properties
self
.
assert
True
(
isinstance
(
mock_property
,
MagicMock
)
)
self
.
assert
IsInstance
(
mock_property
,
MagicMock
)
mock_property
(
1
,
2
,
3
)
mock_property
.
abc
(
4
,
5
,
6
)
mock_property
.
assert_called_once_with
(
1
,
2
,
3
)
...
...
@@ -845,19 +845,19 @@ class TestCallList(unittest.TestCase):
mock
(
b
=
6
)
for
kall
in
call
(
1
,
2
),
call
(
a
=
3
),
call
(
3
,
4
),
call
(
b
=
6
):
self
.
assert
True
(
kall
in
mock
.
call_args_list
)
self
.
assert
In
(
kall
,
mock
.
call_args_list
)
calls
=
[
call
(
a
=
3
),
call
(
3
,
4
)]
self
.
assert
True
(
calls
in
mock
.
call_args_list
)
self
.
assert
In
(
calls
,
mock
.
call_args_list
)
calls
=
[
call
(
1
,
2
),
call
(
a
=
3
)]
self
.
assert
True
(
calls
in
mock
.
call_args_list
)
self
.
assert
In
(
calls
,
mock
.
call_args_list
)
calls
=
[
call
(
3
,
4
),
call
(
b
=
6
)]
self
.
assert
True
(
calls
in
mock
.
call_args_list
)
self
.
assert
In
(
calls
,
mock
.
call_args_list
)
calls
=
[
call
(
3
,
4
)]
self
.
assert
True
(
calls
in
mock
.
call_args_list
)
self
.
assert
In
(
calls
,
mock
.
call_args_list
)
self
.
assert
False
(
call
(
'fish'
)
in
mock
.
call_args_list
)
self
.
assert
False
([
call
(
'fish'
)]
in
mock
.
call_args_list
)
self
.
assert
NotIn
(
call
(
'fish'
),
mock
.
call_args_list
)
self
.
assert
NotIn
([
call
(
'fish'
)],
mock
.
call_args_list
)
def
test_call_list_str
(
self
):
...
...
Lib/unittest/test/testmock/testmagicmethods.py
Dosyayı görüntüle @
bc398690
...
...
@@ -37,12 +37,12 @@ class TestMockingMagicMethods(unittest.TestCase):
return
self
,
'fish'
mock
.
__getitem__
=
f
self
.
assert
False
(
mock
.
__getitem__
is
f
)
self
.
assert
IsNot
(
mock
.
__getitem__
,
f
)
self
.
assertEqual
(
mock
[
'foo'
],
(
mock
,
'fish'
))
self
.
assertEqual
(
mock
.
__getitem__
(
'foo'
),
(
mock
,
'fish'
))
mock
.
__getitem__
=
mock
self
.
assert
True
(
mock
.
__getitem__
is
mock
)
self
.
assert
Is
(
mock
.
__getitem__
,
mock
)
def
test_magic_methods_isolated_between_mocks
(
self
):
...
...
@@ -212,8 +212,8 @@ class TestMockingMagicMethods(unittest.TestCase):
self
.
assertEqual
(
len
(
mock
),
6
)
mock
.
__contains__
=
lambda
s
,
o
:
o
==
3
self
.
assert
True
(
3
in
mock
)
self
.
assert
False
(
6
in
mock
)
self
.
assert
In
(
3
,
mock
)
self
.
assert
NotIn
(
6
,
mock
)
mock
.
__iter__
=
lambda
s
:
iter
(
'foobarbaz'
)
self
.
assertEqual
(
list
(
mock
),
list
(
'foobarbaz'
))
...
...
Lib/unittest/test/testmock/testmock.py
Dosyayı görüntüle @
bc398690
...
...
@@ -64,7 +64,7 @@ class MockTest(unittest.TestCase):
"method_calls not initialised correctly"
)
# Can't use hasattr for this test as it always returns True on a mock
self
.
assert
False
(
'_items'
in
mock
.
__dict__
,
self
.
assert
NotIn
(
'_items'
,
mock
.
__dict__
,
"default mock should not have '_items' attribute"
)
self
.
assertIsNone
(
mock
.
_mock_parent
,
...
...
@@ -565,19 +565,19 @@ class MockTest(unittest.TestCase):
pass
mock
=
Mock
(
spec
=
X
)
self
.
assert
True
(
isinstance
(
mock
,
X
)
)
self
.
assert
IsInstance
(
mock
,
X
)
mock
=
Mock
(
spec
=
X
())
self
.
assert
True
(
isinstance
(
mock
,
X
)
)
self
.
assert
IsInstance
(
mock
,
X
)
self
.
assertIs
(
mock
.
__class__
,
X
)
self
.
assertEqual
(
Mock
()
.
__class__
.
__name__
,
'Mock'
)
mock
=
Mock
(
spec_set
=
X
)
self
.
assert
True
(
isinstance
(
mock
,
X
)
)
self
.
assert
IsInstance
(
mock
,
X
)
mock
=
Mock
(
spec_set
=
X
())
self
.
assert
True
(
isinstance
(
mock
,
X
)
)
self
.
assert
IsInstance
(
mock
,
X
)
def
test_setting_attribute_with_spec_set
(
self
):
...
...
Lib/unittest/test/testmock/testsentinel.py
Dosyayı görüntüle @
bc398690
...
...
@@ -17,7 +17,7 @@ class SentinelTest(unittest.TestCase):
def
testDEFAULT
(
self
):
self
.
assert
True
(
DEFAULT
is
sentinel
.
DEFAULT
)
self
.
assert
Is
(
DEFAULT
,
sentinel
.
DEFAULT
)
def
testBases
(
self
):
# If this doesn't raise an AttributeError then help(mock) is broken
...
...
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