Return number of arguments used up by mock arguments (if any).
(function)
| 87 | |
| 88 | |
| 89 | def 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 | |
| 108 | def getfuncargnames( |