summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/hashlib_helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/support/hashlib_helper.py')
-rw-r--r--Lib/test/support/hashlib_helper.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/test/support/hashlib_helper.py b/Lib/test/support/hashlib_helper.py
index a28132a..a4e6c92 100644
--- a/Lib/test/support/hashlib_helper.py
+++ b/Lib/test/support/hashlib_helper.py
@@ -21,8 +21,21 @@ def requires_hashdigest(digestname, openssl=None, usedforsecurity=True):
ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
ValueError: unsupported hash type md4
"""
- def decorator(func):
- @functools.wraps(func)
+ def decorator(func_or_class):
+ if isinstance(func_or_class, type):
+ setUpClass = func_or_class.__dict__.get('setUpClass')
+ if setUpClass is None:
+ def setUpClass(cls):
+ super(func_or_class, cls).setUpClass()
+ setUpClass.__qualname__ = func_or_class.__qualname__ + '.setUpClass'
+ setUpClass.__module__ = func_or_class.__module__
+ else:
+ setUpClass = setUpClass.__func__
+ setUpClass = classmethod(decorator(setUpClass))
+ func_or_class.setUpClass = setUpClass
+ return func_or_class
+
+ @functools.wraps(func_or_class)
def wrapper(*args, **kwargs):
try:
if openssl and _hashlib is not None:
@@ -33,6 +46,6 @@ def requires_hashdigest(digestname, openssl=None, usedforsecurity=True):
raise unittest.SkipTest(
f"hash digest '{digestname}' is not available."
)
- return func(*args, **kwargs)
+ return func_or_class(*args, **kwargs)
return wrapper
return decorator