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
a74b3aa0
Kaydet (Commit)
a74b3aa0
authored
Mar 14, 2012
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove more Python 2 compatibility cruft from unittest.mock
üst
e7c8fdee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
25 deletions
+6
-25
mock.py
Lib/unittest/mock.py
+4
-11
testcallable.py
Lib/unittest/test/testmock/testcallable.py
+2
-14
No files found.
Lib/unittest/mock.py
Dosyayı görüntüle @
a74b3aa0
...
...
@@ -143,13 +143,10 @@ def _instance_callable(obj):
# already an instance
return
getattr
(
obj
,
'__call__'
,
None
)
is
not
None
klass
=
obj
# uses __bases__ instead of __mro__ so that we work with old style classes
if
klass
.
__dict__
.
get
(
'__call__'
)
is
not
None
:
return
True
for
base
in
klass
.
__bases__
:
if
_instance_callable
(
base
):
# *could* be broken by a class overriding __mro__ or __dict__ via
# a metaclass
for
base
in
(
obj
,)
+
obj
.
__mro__
:
if
base
.
__dict__
.
get
(
'__call__'
)
is
not
None
:
return
True
return
False
...
...
@@ -2064,11 +2061,7 @@ def _must_skip(spec, entry, is_type):
if
entry
in
getattr
(
spec
,
'__dict__'
,
{}):
# instance attribute - shouldn't skip
return
False
# can't use type because of old style classes
spec
=
spec
.
__class__
if
not
hasattr
(
spec
,
'__mro__'
):
# old style class: can't have descriptors anyway
return
is_type
for
klass
in
spec
.
__mro__
:
result
=
klass
.
__dict__
.
get
(
entry
,
DEFAULT
)
...
...
Lib/unittest/test/testmock/testcallable.py
Dosyayı görüntüle @
a74b3aa0
...
...
@@ -107,19 +107,9 @@ class TestCallable(unittest.TestCase):
class
Multi
(
SomeClass
,
Sub
):
pass
class
OldStyle
:
def
__call__
(
self
):
pass
class
OldStyleSub
(
OldStyle
):
pass
for
arg
in
'spec'
,
'spec_set'
:
for
Klass
in
CallableX
,
Sub
,
Multi
,
OldStyle
,
OldStyleSub
:
patcher
=
patch
(
'
%
s.X'
%
__name__
,
**
{
arg
:
Klass
})
mock
=
patcher
.
start
()
try
:
for
Klass
in
CallableX
,
Sub
,
Multi
:
with
patch
(
'
%
s.X'
%
__name__
,
**
{
arg
:
Klass
})
as
mock
:
instance
=
mock
()
mock
.
assert_called_once_with
()
...
...
@@ -136,8 +126,6 @@ class TestCallable(unittest.TestCase):
result
.
assert_called_once_with
(
3
,
2
,
1
)
result
.
foo
(
3
,
2
,
1
)
result
.
foo
.
assert_called_once_with
(
3
,
2
,
1
)
finally
:
patcher
.
stop
()
def
test_create_autopsec
(
self
):
...
...
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