Return mock for instance of `cls` that draws its spec from that class. The mock does not allow new attributes to be set on the instance. If `name` is missing or |None|, the name of the returned |Mock| instance is set to `request.fixturename`. Additional keyword arguments are passed thro
(
request: FixtureRequest,
cls: type,
name: str | None = None,
spec_set: bool = True,
**kwargs: Any,
)
| 70 | |
| 71 | |
| 72 | def instance_mock( |
| 73 | request: FixtureRequest, |
| 74 | cls: type, |
| 75 | name: str | None = None, |
| 76 | spec_set: bool = True, |
| 77 | **kwargs: Any, |
| 78 | ) -> Mock: |
| 79 | """Return mock for instance of `cls` that draws its spec from that class. |
| 80 | |
| 81 | The mock does not allow new attributes to be set on the instance. If `name` is |
| 82 | missing or |None|, the name of the returned |Mock| instance is set to |
| 83 | `request.fixturename`. Additional keyword arguments are passed through to the Mock() |
| 84 | call that creates the mock. |
| 85 | """ |
| 86 | name = name if name is not None else request.fixturename |
| 87 | return create_autospec(cls, _name=name, spec_set=spec_set, instance=True, **kwargs) |
| 88 | |
| 89 | |
| 90 | def loose_mock(request: FixtureRequest, name: str | None = None, **kwargs: Any): |
no outgoing calls
searching dependent graphs…