Return a mock for an instance of `cls` that draws its spec from the class and 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 th
(
request: FixtureRequest,
cls: type,
name: str | None = None,
spec_set: bool = True,
**kwargs: Any,
)
| 86 | |
| 87 | |
| 88 | def instance_mock( |
| 89 | request: FixtureRequest, |
| 90 | cls: type, |
| 91 | name: str | None = None, |
| 92 | spec_set: bool = True, |
| 93 | **kwargs: Any, |
| 94 | ): |
| 95 | """ |
| 96 | Return a mock for an instance of `cls` that draws its spec from the class |
| 97 | and does not allow new attributes to be set on the instance. If `name` is |
| 98 | missing or |None|, the name of the returned |Mock| instance is set to |
| 99 | *request.fixturename*. Additional keyword arguments are passed through to |
| 100 | the Mock() call that creates the mock. |
| 101 | """ |
| 102 | name = name if name is not None else request.fixturename |
| 103 | return create_autospec(cls, _name=name, spec_set=spec_set, instance=True, **kwargs) |
| 104 | |
| 105 | |
| 106 | def loose_mock(request: FixtureRequest, name: str | None = None, **kwargs: Any): |
no outgoing calls
searching dependent graphs…