MCPcopy Create free account
hub / github.com/pytest-dev/pytest / num_mock_patch_args

Function num_mock_patch_args

src/_pytest/compat.py:100–116  ·  view source on GitHub ↗

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

(function)

Source from the content-addressed store, hash-verified

98
99
100def num_mock_patch_args(function) -> int:
101 """Return number of arguments used up by mock arguments (if any)."""
102 patchings = getattr(function, "patchings", None)
103 if not patchings:
104 return 0
105
106 mock_sentinel = getattr(sys.modules.get("mock"), "DEFAULT", object())
107 ut_mock_sentinel = getattr(sys.modules.get("unittest.mock"), "DEFAULT", object())
108
109 return len(
110 [
111 p
112 for p in patchings
113 if not p.attribute_name
114 and (p.new is mock_sentinel or p.new is ut_mock_sentinel)
115 ]
116 )
117
118
119def getfuncargnames(

Callers 1

getfuncargnamesFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected