Return number of arguments used up by mock arguments (if any).
(function)
| 98 | |
| 99 | |
| 100 | def 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 | |
| 119 | def getfuncargnames( |