mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
unittest.mock doc: Fix references to recursive seal of Mocks (GH-9028)
The docs in `library/unittest.mock` have been updated to remove confusing terms about submock and be explicit about the behavior expected.
This commit is contained in:
parent
5a30620e68
commit
96200eb2ff
2 changed files with 9 additions and 9 deletions
|
@ -2425,15 +2425,14 @@ class PropertyMock(Mock):
|
|||
|
||||
|
||||
def seal(mock):
|
||||
"""Disable the automatic generation of "submocks"
|
||||
"""Disable the automatic generation of child mocks.
|
||||
|
||||
Given an input Mock, seals it to ensure no further mocks will be generated
|
||||
when accessing an attribute that was not already defined.
|
||||
|
||||
Submocks are defined as all mocks which were created DIRECTLY from the
|
||||
parent. If a mock is assigned to an attribute of an existing mock,
|
||||
it is not considered a submock.
|
||||
|
||||
The operation recursively seals the mock passed in, meaning that
|
||||
the mock itself, any mocks generated by accessing one of its attributes,
|
||||
and all assigned mocks without a name or spec will be sealed.
|
||||
"""
|
||||
mock._mock_sealed = True
|
||||
for attr in dir(mock):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue