MCPcopy
hub / github.com/pytest-dev/pytest / num_mock_patch_args

Function num_mock_patch_args

src/_pytest/compat.py:89–105  ·  view source on GitHub ↗

Return number of arguments used up by mock arguments (if any).

(function)

Source from the content-addressed store, hash-verified

87
88
89def num_mock_patch_args(function) -> int:
90 """Return number of arguments used up by mock arguments (if any)."""
91 patchings = getattr(function, "patchings", None)
92 if not patchings:
93 return 0
94
95 mock_sentinel = getattr(sys.modules.get("mock"), "DEFAULT", object())
96 ut_mock_sentinel = getattr(sys.modules.get("unittest.mock"), "DEFAULT", object())
97
98 return len(
99 [
100 p
101 for p in patchings
102 if not p.attribute_name
103 and (p.new is mock_sentinel or p.new is ut_mock_sentinel)
104 ]
105 )
106
107
108def getfuncargnames(

Callers 1

getfuncargnamesFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected