|
88 | 88 | "create_empty_file", "can_symlink", "fs_is_case_insensitive", |
89 | 89 | # unittest |
90 | 90 | "is_resource_enabled", "requires", "requires_freebsd_version", |
91 | | - "requires_linux_version", "requires_mac_ver", "requires_hashdigest", |
| 91 | + "requires_linux_version", "requires_mac_ver", |
92 | 92 | "check_syntax_error", "check_syntax_warning", |
93 | 93 | "TransientResource", "time_out", "socket_peer_reset", "ioerror_peer_reset", |
94 | 94 | "transient_internet", "BasicTestRunner", "run_unittest", "run_doctest", |
@@ -588,35 +588,6 @@ def skip_if_buildbot(reason=None): |
588 | 588 | isbuildbot = os.environ.get('USER') == 'buildbot' |
589 | 589 | return unittest.skipIf(isbuildbot, reason) |
590 | 590 |
|
591 | | -def requires_hashdigest(digestname, openssl=None): |
592 | | - """Decorator raising SkipTest if a hashing algorithm is not available |
593 | | -
|
594 | | - The hashing algorithm could be missing or blocked by a strict crypto |
595 | | - policy. |
596 | | -
|
597 | | - If 'openssl' is True, then the decorator checks that OpenSSL provides |
598 | | - the algorithm. Otherwise the check falls back to built-in |
599 | | - implementations. |
600 | | -
|
601 | | - ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS |
602 | | - ValueError: unsupported hash type md4 |
603 | | - """ |
604 | | - def decorator(func): |
605 | | - @functools.wraps(func) |
606 | | - def wrapper(*args, **kwargs): |
607 | | - try: |
608 | | - if openssl and _hashlib is not None: |
609 | | - _hashlib.new(digestname) |
610 | | - else: |
611 | | - hashlib.new(digestname) |
612 | | - except ValueError: |
613 | | - raise unittest.SkipTest( |
614 | | - f"hash digest '{digestname}' is not available." |
615 | | - ) |
616 | | - return func(*args, **kwargs) |
617 | | - return wrapper |
618 | | - return decorator |
619 | | - |
620 | 591 |
|
621 | 592 | HOST = "localhost" |
622 | 593 | HOSTv4 = "127.0.0.1" |
|
0 commit comments