MCPcopy Index your code
hub / github.com/python-openxml/python-docx / instance_mock

Function instance_mock

tests/unitutil/mock.py:88–103  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

86
87
88def 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
106def loose_mock(request: FixtureRequest, name: str | None = None, **kwargs: Any):

Callers 15

document_Method · 0.85
document_part_Method · 0.85
merged_tc_Method · 0.85
parent_Method · 0.85
tc_Method · 0.85
tc_2_Method · 0.85
parent_Method · 0.85
table_Method · 0.85
table_Method · 0.85
parent_Method · 0.85
table_Method · 0.85
parent_Method · 0.85

Calls

no outgoing calls

Tested by 15

document_Method · 0.68
document_part_Method · 0.68
merged_tc_Method · 0.68
parent_Method · 0.68
tc_Method · 0.68
tc_2_Method · 0.68
parent_Method · 0.68
table_Method · 0.68
table_Method · 0.68
parent_Method · 0.68
table_Method · 0.68
parent_Method · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…