(
self, getter, attribute, new, spec, create,
spec_set, autospec, new_callable, kwargs, *, unsafe=False
)
| 1278 | _active_patches = [] |
| 1279 | |
| 1280 | def __init__( |
| 1281 | self, getter, attribute, new, spec, create, |
| 1282 | spec_set, autospec, new_callable, kwargs, *, unsafe=False |
| 1283 | ): |
| 1284 | if new_callable is not None: |
| 1285 | if new is not DEFAULT: |
| 1286 | raise ValueError( |
| 1287 | "Cannot use 'new' and 'new_callable' together" |
| 1288 | ) |
| 1289 | if autospec is not None: |
| 1290 | raise ValueError( |
| 1291 | "Cannot use 'autospec' and 'new_callable' together" |
| 1292 | ) |
| 1293 | if not unsafe: |
| 1294 | _check_spec_arg_typos(kwargs) |
| 1295 | if _is_instance_mock(spec): |
| 1296 | raise InvalidSpecError( |
| 1297 | f'Cannot spec attr {attribute!r} as the spec ' |
| 1298 | f'has already been mocked out. [spec={spec!r}]') |
| 1299 | if _is_instance_mock(spec_set): |
| 1300 | raise InvalidSpecError( |
| 1301 | f'Cannot spec attr {attribute!r} as the spec_set ' |
| 1302 | f'target has already been mocked out. [spec_set={spec_set!r}]') |
| 1303 | |
| 1304 | self.getter = getter |
| 1305 | self.attribute = attribute |
| 1306 | self.new = new |
| 1307 | self.new_callable = new_callable |
| 1308 | self.spec = spec |
| 1309 | self.create = create |
| 1310 | self.has_local = False |
| 1311 | self.spec_set = spec_set |
| 1312 | self.autospec = autospec |
| 1313 | self.kwargs = kwargs |
| 1314 | self.additional_patchers = [] |
| 1315 | |
| 1316 | |
| 1317 | def copy(self): |
nothing calls this directly
no test coverage detected