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
d2623d77
Kaydet (Commit)
d2623d77
authored
Nis 14, 2014
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 20968. unittest.mock.MagicMock now supports division
üst
604453c9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
mock.py
Lib/unittest/mock.py
+3
-1
testmagicmethods.py
Lib/unittest/test/testmock/testmagicmethods.py
+25
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/mock.py
Dosyayı görüntüle @
d2623d77
...
...
@@ -1634,7 +1634,9 @@ magic_methods = (
"bool next "
)
numerics
=
"add sub mul div floordiv mod lshift rshift and xor or pow "
numerics
=
(
"add sub mul div floordiv mod lshift rshift and xor or pow truediv"
)
inplace
=
' '
.
join
(
'i
%
s'
%
n
for
n
in
numerics
.
split
())
right
=
' '
.
join
(
'r
%
s'
%
n
for
n
in
numerics
.
split
())
...
...
Lib/unittest/test/testmock/testmagicmethods.py
Dosyayı görüntüle @
d2623d77
...
...
@@ -126,6 +126,31 @@ class TestMockingMagicMethods(unittest.TestCase):
self
.
assertEqual
(
7
+
mock
,
mock
)
self
.
assertEqual
(
mock
.
value
,
16
)
def
test_division
(
self
):
original
=
mock
=
Mock
()
mock
.
value
=
32
self
.
assertRaises
(
TypeError
,
lambda
:
mock
/
2
)
def
truediv
(
self
,
other
):
mock
.
value
/=
other
return
self
mock
.
__truediv__
=
truediv
self
.
assertEqual
(
mock
/
2
,
mock
)
self
.
assertEqual
(
mock
.
value
,
16
)
del
mock
.
__truediv__
def
itruediv
(
mock
):
mock
/=
4
self
.
assertRaises
(
TypeError
,
itruediv
,
mock
)
mock
.
__itruediv__
=
truediv
mock
/=
8
self
.
assertEqual
(
mock
,
original
)
self
.
assertEqual
(
mock
.
value
,
2
)
self
.
assertRaises
(
TypeError
,
lambda
:
8
/
mock
)
mock
.
__rtruediv__
=
truediv
self
.
assertEqual
(
0.5
/
mock
,
mock
)
self
.
assertEqual
(
mock
.
value
,
4
)
def
test_hash
(
self
):
mock
=
Mock
()
...
...
Misc/NEWS
Dosyayı görüntüle @
d2623d77
...
...
@@ -30,6 +30,9 @@ Core and Builtins
Library
-------
- Issue #20968: unittest.mock.MagicMock now supports division.
Patch by Johannes Baiter.
- Fix arbitrary memory access in JSONDecoder.raw_decode with a negative second
parameter. Bug reported by Guido Vranken.
...
...
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