Check availability of _hashlib.new(digestname, **kwargs). The constructor function is returned (without binding **kwargs), or SkipTest is raised if none exists.
(digestname, /, **kwargs)
| 644 | |
| 645 | |
| 646 | def _openssl_new(digestname, /, **kwargs): |
| 647 | """Check availability of _hashlib.new(digestname, **kwargs). |
| 648 | |
| 649 | The constructor function is returned (without binding **kwargs), |
| 650 | or SkipTest is raised if none exists. |
| 651 | """ |
| 652 | assert isinstance(digestname, str), digestname |
| 653 | try: |
| 654 | # re-import '_hashlib' in case it was mocked |
| 655 | _hashlib = importlib.import_module("_hashlib") |
| 656 | except ImportError as exc: |
| 657 | raise SkipNoHash(digestname, "openssl") from exc |
| 658 | try: |
| 659 | _hashlib.new(digestname, **kwargs) |
| 660 | except ValueError as exc: |
| 661 | raise SkipNoHashInCall("_hashlib.new", digestname) from exc |
| 662 | return functools.partial(_hashlib.new, digestname) |
| 663 | |
| 664 | |
| 665 | def _openssl_hash(digestname, /, **kwargs): |
nothing calls this directly
no test coverage detected
searching dependent graphs…