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
d7c65e28
Kaydet (Commit)
d7c65e28
authored
Mar 14, 2012
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed XXX from unittest.mock docstring and switch to a nicer try...except...finally
üst
30162be9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
mock.py
Lib/unittest/mock.py
+19
-24
No files found.
Lib/unittest/mock.py
Dosyayı görüntüle @
d7c65e28
...
@@ -619,9 +619,7 @@ class NonCallableMock(Base):
...
@@ -619,9 +619,7 @@ class NonCallableMock(Base):
def
__dir__
(
self
):
def
__dir__
(
self
):
"""Filter the output of `dir(mock)` to only useful members.
"""Filter the output of `dir(mock)` to only useful members."""
XXXX
"""
extras
=
self
.
_mock_methods
or
[]
extras
=
self
.
_mock_methods
or
[]
from_type
=
dir
(
type
(
self
))
from_type
=
dir
(
type
(
self
))
from_dict
=
list
(
self
.
__dict__
)
from_dict
=
list
(
self
.
__dict__
)
...
@@ -1057,31 +1055,28 @@ class _patch(object):
...
@@ -1057,31 +1055,28 @@ class _patch(object):
@wraps
(
func
)
@wraps
(
func
)
def
patched
(
*
args
,
**
keywargs
):
def
patched
(
*
args
,
**
keywargs
):
# could use with statement here
extra_args
=
[]
extra_args
=
[]
entered_patchers
=
[]
entered_patchers
=
[]
# could use try..except...finally here
try
:
try
:
try
:
for
patching
in
patched
.
patchings
:
for
patching
in
patched
.
patchings
:
arg
=
patching
.
__enter__
()
arg
=
patching
.
__enter__
()
entered_patchers
.
append
(
patching
)
entered_patchers
.
append
(
patching
)
if
patching
.
attribute_name
is
not
None
:
if
patching
.
attribute_name
is
not
None
:
keywargs
.
update
(
arg
)
keywargs
.
update
(
arg
)
elif
patching
.
new
is
DEFAULT
:
elif
patching
.
new
is
DEFAULT
:
extra_args
.
append
(
arg
)
extra_args
.
append
(
arg
)
args
+=
tuple
(
extra_args
)
args
+=
tuple
(
extra_args
)
return
func
(
*
args
,
**
keywargs
)
return
func
(
*
args
,
**
keywargs
)
except
:
except
:
if
(
patching
not
in
entered_patchers
and
if
(
patching
not
in
entered_patchers
and
_is_started
(
patching
)):
_is_started
(
patching
)):
# the patcher may have been started, but an exception
# the patcher may have been started, but an exception
# raised whilst entering one of its additional_patchers
# raised whilst entering one of its additional_patchers
entered_patchers
.
append
(
patching
)
entered_patchers
.
append
(
patching
)
# re-raise the exception
# re-raise the exception
raise
raise
finally
:
finally
:
for
patching
in
reversed
(
entered_patchers
):
for
patching
in
reversed
(
entered_patchers
):
patching
.
__exit__
()
patching
.
__exit__
()
...
...
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