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
54b3db8c
Kaydet (Commit)
54b3db8c
authored
Mar 28, 2012
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Minor unittest.mock.patch doc / docstring improvement
üst
a9e6fb20
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
22 deletions
+30
-22
unittest.mock.rst
Doc/library/unittest.mock.rst
+14
-11
mock.py
Lib/unittest/mock.py
+16
-11
No files found.
Doc/library/unittest.mock.rst
Dosyayı görüntüle @
54b3db8c
...
...
@@ -920,17 +920,20 @@ patch
`patch` acts as a function decorator, class decorator or a context
manager. Inside the body of the function or with statement, the `target`
(specified in the form `'package.module.ClassName'`) is patched
with a `new` object. When the function/with statement exits the patch is
undone.
The `target` is imported and the specified attribute patched with the new
object, so it must be importable from the environment you are calling the
decorator from. The target is imported when the decorated function is
executed, not at decoration time.
If `new` is omitted, then a new `MagicMock` is created and passed in as an
extra argument to the decorated function.
is patched with a `new` object. When the function/with statement exits
the patch is undone.
If `new` is omitted, then the target is replaced with a
:class:`MagicMock`. If `patch` is used as a decorator and `new` is
omitted, the created mock is passed in as an extra argument to the
decorated function. If `patch` is used as a context manager the created
mock is returned by the context manager.
`target` should be a string in the form `'package.module.ClassName'`. The
`target` is imported and the specified object replaced with the `new`
object, so the `target` must be importable from the environment you are
calling `patch` from. The target is imported when the decorated function
is executed, not at decoration time.
The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
if patch is creating one for you.
...
...
Lib/unittest/mock.py
Dosyayı görüntüle @
54b3db8c
...
...
@@ -1351,18 +1351,23 @@ def patch(
):
"""
`patch` acts as a function decorator, class decorator or a context
manager. Inside the body of the function or with statement, the `target`
(specified in the form `'package.module.ClassName'`) is patched
with a `new` object. When the function/with statement exits the patch is
undone.
The `target` is imported and the specified attribute patched with the new
object, so it must be importable from the environment you are calling the
decorator from. The target is imported when the decorated function is
executed, not at decoration time.
If `new` is omitted, then a new `MagicMock` is created and passed in as an
extra argument to the decorated function.
`patch` acts as a function decorator, class decorator or a context
manager. Inside the body of the function or with statement, the `target`
is patched with a `new` object. When the function/with statement exits
the patch is undone.
If `new` is omitted, then the target is replaced with a
`MagicMock`. If `patch` is used as a decorator and `new` is
omitted, the created mock is passed in as an extra argument to the
decorated function. If `patch` is used as a context manager the created
mock is returned by the context manager.
`target` should be a string in the form `'package.module.ClassName'`. The
`target` is imported and the specified object replaced with the `new`
object, so the `target` must be importable from the environment you are
calling `patch` from. The target is imported when the decorated function
is executed, not at decoration time.
The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
if patch is creating one for you.
...
...
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