MCPcopy Index your code
hub / github.com/RustPython/RustPython / mock_add_spec

Method mock_add_spec

Lib/unittest/mock.py:2229–2236  ·  view source on GitHub ↗

Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.

(self, spec, spec_set=False)

Source from the content-addressed store, hash-verified

2227 Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
2228 """
2229 def mock_add_spec(self, spec, spec_set=False):
2230 """Add a spec to a mock. `spec` can either be an object or a
2231 list of strings. Only attributes on the `spec` can be fetched as
2232 attributes from the mock.
2233
2234 If `spec_set` is True then only attributes on the spec can be set."""
2235 self._mock_add_spec(spec, spec_set)
2236 self._mock_set_magics()
2237
2238 def reset_mock(self, /, *args, return_value: bool = False, **kwargs):
2239 if (

Callers 2

test_mock_add_specMethod · 0.45

Calls 2

_mock_add_specMethod · 0.80
_mock_set_magicsMethod · 0.80

Tested by 2

test_mock_add_specMethod · 0.36