summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2021-09-04 20:42:36 (GMT)
committerGitHub <noreply@github.com>2021-09-04 20:42:36 (GMT)
commitdd7b816ac87e468e2fa65ce83c2a03fe1da8503e (patch)
tree12001af79d0e03ee96993f5a3d2084de52e3db31 /Lib/test
parenta1ba3597d2d2dd5e5d73f42b1174ab5e0a2cd224 (diff)
downloadcpython-dd7b816ac87e468e2fa65ce83c2a03fe1da8503e.zip
cpython-dd7b816ac87e468e2fa65ce83c2a03fe1da8503e.tar.gz
cpython-dd7b816ac87e468e2fa65ce83c2a03fe1da8503e.tar.bz2
bpo-45042: Now test classes decorated with `requires_hashdigest` are not skipped (GH-28060)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/_test_multiprocessing.py1
-rw-r--r--Lib/test/support/hashlib_helper.py19
-rw-r--r--Lib/test/test_tools/test_md5sum.py7
3 files changed, 21 insertions, 6 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 7e0b757..0f4e4fd 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3773,6 +3773,7 @@ class _TestSharedMemory(BaseTestCase):
local_sms.buf[:len(binary_data)] = binary_data
local_sms.close()
+ @unittest.skipIf(sys.platform == "win32", "test is broken on Windows")
def test_shared_memory_basics(self):
sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512)
self.addCleanup(sms.unlink)
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
diff --git a/Lib/test/test_tools/test_md5sum.py b/Lib/test/test_tools/test_md5sum.py
index bfc1f28..92315f1 100644
--- a/Lib/test/test_tools/test_md5sum.py
+++ b/Lib/test/test_tools/test_md5sum.py
@@ -1,5 +1,6 @@
"""Tests for the md5sum script in the Tools directory."""
+import sys
import os
import unittest
from test.support import os_helper
@@ -15,8 +16,8 @@ class MD5SumTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.script = os.path.join(scriptsdir, 'md5sum.py')
- os.mkdir(os_helper.TESTFN)
- cls.fodder = os.path.join(os_helper.TESTFN, 'md5sum.fodder')
+ os.mkdir(os_helper.TESTFN_ASCII)
+ cls.fodder = os.path.join(os_helper.TESTFN_ASCII, 'md5sum.fodder')
with open(cls.fodder, 'wb') as f:
f.write(b'md5sum\r\ntest file\r\n')
cls.fodder_md5 = b'd38dae2eb1ab346a292ef6850f9e1a0d'
@@ -24,7 +25,7 @@ class MD5SumTests(unittest.TestCase):
@classmethod
def tearDownClass(cls):
- os_helper.rmtree(os_helper.TESTFN)
+ os_helper.rmtree(os_helper.TESTFN_ASCII)
def test_noargs(self):
rc, out, err = assert_python_ok(self.script)