(blocked_name)
| 934 | |
| 935 | |
| 936 | def _block_builtin_hmac_new(blocked_name): |
| 937 | assert isinstance(blocked_name, str), blocked_name |
| 938 | |
| 939 | # re-import '_hmac' in case it was mocked |
| 940 | if (_hmac := _import_module("_hmac")) is None: |
| 941 | return contextlib.nullcontext() |
| 942 | |
| 943 | @functools.wraps(wrapped := _hmac.new) |
| 944 | def _hmac_new(key, msg=None, digestmod=None): |
| 945 | if digestmod == blocked_name: |
| 946 | raise _hmac.UnknownHashError(blocked_name) |
| 947 | return wrapped(key, msg, digestmod) |
| 948 | |
| 949 | _ensure_wrapper_signature(_hmac_new, wrapped) |
| 950 | return unittest.mock.patch('_hmac.new', _hmac_new) |
| 951 | |
| 952 | |
| 953 | def _block_builtin_hmac_digest(blocked_name): |
no test coverage detected
searching dependent graphs…