MCPcopy Create free account
hub / github.com/scanny/python-pptx / instance_mock

Function instance_mock

tests/unitutil/mock.py:72–87  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

70
71
72def 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
90def loose_mock(request: FixtureRequest, name: str | None = None, **kwargs: Any):

Callers 15

cell_Method · 0.85
graphic_frame_Method · 0.85
tbl_Method · 0.85
tc_Method · 0.85
tc_range_Method · 0.85
text_frame_Method · 0.85
iter_fixtureMethod · 0.85
cell_Method · 0.85
parent_Method · 0.85

Calls

no outgoing calls

Tested by 15

cell_Method · 0.68
graphic_frame_Method · 0.68
tbl_Method · 0.68
tc_Method · 0.68
tc_range_Method · 0.68
text_frame_Method · 0.68
iter_fixtureMethod · 0.68
cell_Method · 0.68
parent_Method · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…