Lines Matching refs:spec_set
428 spec_arg = bound_args.get('spec_set', bound_args.get('spec'))
437 self, spec=None, wraps=None, name=None, spec_set=None,
451 if spec_set is not None:
452 spec = spec_set
453 spec_set = True
457 self._mock_add_spec(spec, spec_set, _spec_as_instance, _eat_self)
476 spec, wraps, name, spec_set, parent,
496 def mock_add_spec(self, spec, spec_set=False):
501 If `spec_set` is True then only attributes on the spec can be set."""
502 self._mock_add_spec(spec, spec_set)
505 def _mock_add_spec(self, spec, spec_set, _spec_as_instance=False,
531 __dict__['_spec_set'] = spec_set
682 result.spec, result.spec_set, result.instance,
734 spec_string = ' spec_set=%r'
1103 wraps=None, name=None, spec_set=None, parent=None,
1107 spec, wraps, name, spec_set, parent,
1219 * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
1221 `spec_set` will raise an `AttributeError`.
1279 spec_set, autospec, new_callable, kwargs, *, unsafe=False
1296 if _is_instance_mock(spec_set):
1298 f'Cannot spec attr {attribute!r} as the spec_set '
1299 f'target has already been mocked out. [spec_set={spec_set!r}]')
1308 self.spec_set = spec_set
1317 self.create, self.spec_set,
1424 new, spec, spec_set = self.new, self.spec, self.spec_set
1432 if spec_set is False:
1433 spec_set = None
1440 spec_set not in (True, None)):
1441 raise TypeError("Can't provide explicit spec_set *and* spec or autospec")
1450 if spec_set is True:
1451 spec_set = original
1454 if spec_set is True:
1455 spec_set = spec
1457 elif spec_set is True:
1458 spec_set = original
1460 if spec is not None or spec_set is not None:
1473 elif spec is not None or spec_set is not None:
1475 if spec_set is not None:
1476 this_spec = spec_set
1488 if spec_set is not None:
1489 _kwargs['spec_set'] = spec_set
1503 if spec_set is not None:
1504 this_spec = spec_set
1513 # spec is ignored, new *must* be default, spec_set is treated
1514 # as a boolean. Should we check spec is not None and that spec_set
1523 spec_set = bool(spec_set)
1539 new = create_autospec(autospec, spec_set=spec_set,
1619 create=False, spec_set=None, autospec=None,
1627 manager. Arguments `new`, `spec`, `create`, `spec_set`,
1642 spec_set, autospec, new_callable, kwargs, unsafe=unsafe
1646 def _patch_multiple(target, spec=None, create=False, spec_set=None,
1661 manager. The arguments `spec`, `spec_set`, `create`,
1681 getter, attribute, new, spec, create, spec_set,
1687 getter, attribute, new, spec, create, spec_set,
1697 spec_set=None, autospec=None, new_callable=None, *, unsafe=False, **kwargs
1718 The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
1721 In addition you can pass `spec=True` or `spec_set=True`, which causes
1722 patch to pass in the object being mocked as the spec/spec_set object.
1760 the arguments autospec and spec_set. Pass the argument `unsafe` with the
1773 spec_set, autospec, new_callable, kwargs, unsafe=unsafe
2136 def mock_add_spec(self, spec, spec_set=False):
2141 If `spec_set` is True then only attributes on the spec can be set."""
2142 self._mock_add_spec(spec, spec_set)
2158 If you use the `spec` or `spec_set` arguments then *only* magic
2163 def mock_add_spec(self, spec, spec_set=False):
2168 If `spec_set` is True then only attributes on the spec can be set."""
2169 self._mock_add_spec(spec, spec_set)
2203 # It is set through __dict__ because when spec_set is True, this
2209 code_mock = NonCallableMock(spec_set=CodeType)
2652 def create_autospec(spec, spec_set=False, instance=False, _parent=None,
2661 If `spec_set` is True then attempting to set attributes that don't exist
2670 misspellings of the arguments autospec and spec_set. Pass the argument
2686 if spec_set:
2687 _kwargs = {'spec_set': spec}
2736 mock.return_value = create_autospec(spec, spec_set, instance=True,
2759 if spec_set:
2760 kwargs = {'spec_set': original}
2763 new = _SpecState(original, spec_set, mock, entry, instance)
2822 def __init__(self, spec, spec_set=False, parent=None,
2826 self.spec_set = spec_set
2981 code_mock = NonCallableMock(spec_set=CodeType)