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.
(cherry picked from commit 96200eb2ffcda05de14099cf23f60d5091366e3e)
Co-authored-by: Mario Corchero <mariocj89@gmail.com>
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index cfc0d76..1a6c251 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -2423,15 +2423,14 @@
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):