summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--Misc/NEWS.d/next/Tests/2021-08-30-11-54-14.bpo-45042.QMz3X8.rst1
4 files changed, 22 insertions, 6 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 4c4da24..a7cc1e5 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3771,6 +3771,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)
diff --git a/Misc/NEWS.d/next/Tests/2021-08-30-11-54-14.bpo-45042.QMz3X8.rst b/Misc/NEWS.d/next/Tests/2021-08-30-11-54-14.bpo-45042.QMz3X8.rst
new file mode 100644
index 0000000..e2c0dff
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-08-30-11-54-14.bpo-45042.QMz3X8.rst
@@ -0,0 +1 @@
+Fixes that test classes decorated with ``@hashlib_helper.requires_hashdigest`` were skipped all the time. \ No newline at end of file