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
99254730
Kaydet (Commit)
99254730
authored
Mar 25, 2012
tarafından
Michael Foord
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Addition of docstrings to unittest.mock helpers
üst
a74561a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
mock.py
Lib/unittest/mock.py
+20
-2
No files found.
Lib/unittest/mock.py
Dosyayı görüntüle @
99254730
...
@@ -1205,7 +1205,7 @@ class _patch(object):
...
@@ -1205,7 +1205,7 @@ class _patch(object):
"autospec and new."
"autospec and new."
)
)
if
original
is
DEFAULT
:
if
original
is
DEFAULT
:
raise
TypeError
(
"Can't use 'spec' with create=True"
)
raise
TypeError
(
"Can't use '
auto
spec' with create=True"
)
spec_set
=
bool
(
spec_set
)
spec_set
=
bool
(
spec_set
)
if
autospec
is
True
:
if
autospec
is
True
:
autospec
=
original
autospec
=
original
...
@@ -2142,6 +2142,17 @@ FunctionAttributes = set([
...
@@ -2142,6 +2142,17 @@ FunctionAttributes = set([
file_spec
=
None
file_spec
=
None
def
mock_open
(
mock
=
None
,
read_data
=
None
):
def
mock_open
(
mock
=
None
,
read_data
=
None
):
"""
A helper function to create a mock to replace the use of `open`. It works
for `open` called directly or used as a context manager.
The `mock` argument is the mock object to configure. If `None` (the
default) then a `MagicMock` will be created for you, with the API limited
to methods or attributes available on standard file handles.
`read_data` is a string for the `read` method of the file handle to return.
This is an empty string by default.
"""
global
file_spec
global
file_spec
if
file_spec
is
None
:
if
file_spec
is
None
:
import
_io
import
_io
...
@@ -2162,7 +2173,14 @@ def mock_open(mock=None, read_data=None):
...
@@ -2162,7 +2173,14 @@ def mock_open(mock=None, read_data=None):
class
PropertyMock
(
Mock
):
class
PropertyMock
(
Mock
):
"""A Mock variant with __get__ and __set__ methods to act as a property"""
"""
A mock intended to be used as a property, or other descriptor, on a class.
`PropertyMock` provides `__get__` and `__set__` methods so you can specify
a return value when it is fetched.
Fetching a `PropertyMock` instance from an object calls the mock, with
no args. Setting it calls the mock with the value being set.
"""
def
__get__
(
self
,
obj
,
obj_type
):
def
__get__
(
self
,
obj
,
obj_type
):
return
self
()
return
self
()
def
__set__
(
self
,
obj
,
val
):
def
__set__
(
self
,
obj
,
val
):
...
...
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