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
28d591ce
Kaydet (Commit)
28d591ce
authored
Eyl 28, 2012
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closes issue 15323. Improve failure message of Mock.assert_called_once_with
üst
49450275
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
4 deletions
+13
-4
unittest.mock.rst
Doc/library/unittest.mock.rst
+2
-2
mock.py
Lib/unittest/mock.py
+2
-2
testmock.py
Lib/unittest/test/testmock/testmock.py
+7
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/unittest.mock.rst
Dosyayı görüntüle @
28d591ce
...
...
@@ -276,7 +276,7 @@ the `new_callable` argument to `patch`.
>>> mock.assert_called_once_with('foo', bar='baz')
Traceback (most recent call last):
...
AssertionError: Expected to be called once. Called 2 times.
AssertionError: Expected
'mock'
to be called once. Called 2 times.
.. method:: assert_any_call(*args, **kwargs)
...
...
@@ -2020,7 +2020,7 @@ extremely handy: :meth:`~Mock.assert_called_with` and
>>> mock.assert_called_once_with(1, 2, 3)
Traceback (most recent call last):
...
AssertionError: Expected to be called once. Called 2 times.
AssertionError: Expected
'mock'
to be called once. Called 2 times.
Because mocks auto-create attributes on demand, and allow you to call them
with arbitrary arguments, if you misspell one of these assert methods then
...
...
Lib/unittest/mock.py
Dosyayı görüntüle @
28d591ce
...
...
@@ -731,8 +731,8 @@ class NonCallableMock(Base):
arguments."""
self
=
_mock_self
if
not
self
.
call_count
==
1
:
msg
=
(
"Expected to be called once. Called
%
s times."
%
self
.
call_count
)
msg
=
(
"Expected
'
%
s'
to be called once. Called
%
s times."
%
(
self
.
_mock_name
or
'mock'
,
self
.
call_count
)
)
raise
AssertionError
(
msg
)
return
self
.
assert_called_with
(
*
args
,
**
kwargs
)
...
...
Lib/unittest/test/testmock/testmock.py
Dosyayı görüntüle @
28d591ce
...
...
@@ -463,6 +463,13 @@ class MockTest(unittest.TestCase):
mock
.
assert_called_with
)
def
test_assert_called_once_with_message
(
self
):
mock
=
Mock
(
name
=
'geoffrey'
)
self
.
assertRaisesRegex
(
AssertionError
,
r"Expected 'geoffrey' to be called once\."
,
mock
.
assert_called_once_with
)
def
test__name__
(
self
):
mock
=
Mock
()
self
.
assertRaises
(
AttributeError
,
lambda
:
mock
.
__name__
)
...
...
Misc/NEWS
Dosyayı görüntüle @
28d591ce
...
...
@@ -36,6 +36,8 @@ Core and Builtins
Library
-------
- Issue #15323: improve failure message of Mock.assert_called_once_with
- Issue #16064: unittest -m claims executable is "python", not "python3"
- Issue #12376: Pass on parameters in TextTestResult.__init__ super call
...
...
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