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
2bdd5858
Kaydet (Commit)
2bdd5858
authored
Şub 14, 2019
tarafından
Susan Su
Kaydeden (comit)
Lisa Roach
Şub 14, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-35500: align expected and actual calls on mock.assert_called_with error message. (GH-11804)
üst
1dc5cb9c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
mock.py
Lib/unittest/mock.py
+5
-2
testmock.py
Lib/unittest/test/testmock/testmock.py
+8
-7
2019-02-10-00-00-13.bpo-35500.1HOMmo.rst
...S.d/next/Library/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst
+1
-0
No files found.
Lib/unittest/mock.py
Dosyayı görüntüle @
2bdd5858
...
...
@@ -745,7 +745,7 @@ class NonCallableMock(Base):
def
_format_mock_failure_message
(
self
,
args
,
kwargs
):
message
=
'
Expected call:
%
s
\n
Actual cal
l:
%
s'
message
=
'
expected call not found.
\n
Expected:
%
s
\n
Actua
l:
%
s'
expected_string
=
self
.
_format_mock_call_signature
(
args
,
kwargs
)
call_args
=
self
.
call_args
if
len
(
call_args
)
==
3
:
...
...
@@ -814,7 +814,10 @@ class NonCallableMock(Base):
self
=
_mock_self
if
self
.
call_args
is
None
:
expected
=
self
.
_format_mock_call_signature
(
args
,
kwargs
)
raise
AssertionError
(
'Expected call:
%
s
\n
Not called'
%
(
expected
,))
actual
=
'not called.'
error_message
=
(
'expected call not found.
\n
Expected:
%
s
\n
Actual:
%
s'
%
(
expected
,
actual
))
raise
AssertionError
(
error_message
)
def
_error_message
():
msg
=
self
.
_format_mock_failure_message
(
args
,
kwargs
)
...
...
Lib/unittest/test/testmock/testmock.py
Dosyayı görüntüle @
2bdd5858
...
...
@@ -724,7 +724,7 @@ class MockTest(unittest.TestCase):
def
test_assert_called_with_message
(
self
):
mock
=
Mock
()
self
.
assertRaisesRegex
(
AssertionError
,
'
N
ot called'
,
self
.
assertRaisesRegex
(
AssertionError
,
'
n
ot called'
,
mock
.
assert_called_with
)
...
...
@@ -917,10 +917,11 @@ class MockTest(unittest.TestCase):
def
test_assert_called_with_failure_message
(
self
):
mock
=
NonCallableMock
()
actual
=
'not called.'
expected
=
"mock(1, '2', 3, bar='foo')"
message
=
'
Expected call:
%
s
\n
Not called
'
message
=
'
expected call not found.
\n
Expected:
%
s
\n
Actual:
%
s
'
self
.
assertRaisesWithMsg
(
AssertionError
,
message
%
(
expected
,),
AssertionError
,
message
%
(
expected
,
actual
),
mock
.
assert_called_with
,
1
,
'2'
,
3
,
bar
=
'foo'
)
...
...
@@ -933,7 +934,7 @@ class MockTest(unittest.TestCase):
for
meth
in
asserters
:
actual
=
"foo(1, '2', 3, foo='foo')"
expected
=
"foo(1, '2', 3, bar='foo')"
message
=
'
Expected call:
%
s
\n
Actual cal
l:
%
s'
message
=
'
expected call not found.
\n
Expected:
%
s
\n
Actua
l:
%
s'
self
.
assertRaisesWithMsg
(
AssertionError
,
message
%
(
expected
,
actual
),
meth
,
1
,
'2'
,
3
,
bar
=
'foo'
...
...
@@ -943,7 +944,7 @@ class MockTest(unittest.TestCase):
for
meth
in
asserters
:
actual
=
"foo(1, '2', 3, foo='foo')"
expected
=
"foo(bar='foo')"
message
=
'
Expected call:
%
s
\n
Actual cal
l:
%
s'
message
=
'
expected call not found.
\n
Expected:
%
s
\n
Actua
l:
%
s'
self
.
assertRaisesWithMsg
(
AssertionError
,
message
%
(
expected
,
actual
),
meth
,
bar
=
'foo'
...
...
@@ -953,7 +954,7 @@ class MockTest(unittest.TestCase):
for
meth
in
asserters
:
actual
=
"foo(1, '2', 3, foo='foo')"
expected
=
"foo(1, 2, 3)"
message
=
'
Expected call:
%
s
\n
Actual cal
l:
%
s'
message
=
'
expected call not found.
\n
Expected:
%
s
\n
Actua
l:
%
s'
self
.
assertRaisesWithMsg
(
AssertionError
,
message
%
(
expected
,
actual
),
meth
,
1
,
2
,
3
...
...
@@ -963,7 +964,7 @@ class MockTest(unittest.TestCase):
for
meth
in
asserters
:
actual
=
"foo(1, '2', 3, foo='foo')"
expected
=
"foo()"
message
=
'
Expected call:
%
s
\n
Actual cal
l:
%
s'
message
=
'
expected call not found.
\n
Expected:
%
s
\n
Actua
l:
%
s'
self
.
assertRaisesWithMsg
(
AssertionError
,
message
%
(
expected
,
actual
),
meth
)
...
...
Misc/NEWS.d/next/Library/2019-02-10-00-00-13.bpo-35500.1HOMmo.rst
0 → 100644
Dosyayı görüntüle @
2bdd5858
Write expected and actual call parameters on separate lines in :meth:`unittest.mock.Mock.assert_called_with` assertion errors. Contributed by Susan Su.
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