[Python-checkins] bpo-28668: test.support.requires_multiprocessing_queue is removed (GH-4560)
xdegaye
webhook-mailer at python.org
Fri Dec 1 02:08:52 EST 2017
https://github.com/python/cpython/commit/bf2b65e413ca5ec705c7e2f463d0d75e947588a4
commit: bf2b65e413ca5ec705c7e2f463d0d75e947588a4
branch: master
author: xdegaye <xdegaye at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-12-01T08:08:49+01:00
summary:
bpo-28668: test.support.requires_multiprocessing_queue is removed (GH-4560)
Skip tests with test.support.import_module('multiprocessing.synchronize')
instead when the semaphore implementation is broken or missing.
files:
A Misc/NEWS.d/next/Tests/2017-11-25-14-53-29.bpo-28668.Y1G6pA.rst
M Lib/test/support/__init__.py
M Lib/test/test_logging.py
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index f0e15078d62..22868d4ba1a 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -87,8 +87,7 @@
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
"requires_IEEE_754", "skip_unless_xattr", "requires_zlib",
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
- "check__all__", "requires_multiprocessing_queue",
- "skip_unless_bind_unix_socket",
+ "check__all__", "skip_unless_bind_unix_socket",
# sys
"is_jython", "is_android", "check_impl_detail", "unix_shell",
"setswitchinterval",
@@ -1791,22 +1790,6 @@ def impl_detail(msg=None, **guards):
msg = msg.format(' or '.join(guardnames))
return unittest.skip(msg)
-_have_mp_queue = None
-def requires_multiprocessing_queue(test):
- """Skip decorator for tests that use multiprocessing.Queue."""
- global _have_mp_queue
- if _have_mp_queue is None:
- import multiprocessing
- # Without a functioning shared semaphore implementation attempts to
- # instantiate a Queue will result in an ImportError (issue #3770).
- try:
- multiprocessing.Queue()
- _have_mp_queue = True
- except ImportError:
- _have_mp_queue = False
- msg = "requires a functioning shared semaphore implementation"
- return test if _have_mp_queue else unittest.skip(msg)(test)
-
def _parse_guards(guards):
# Returns a tuple ({platform_name: run_me}, default_value)
if not guards:
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 1968b4253c2..7101e3b1576 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3211,9 +3211,11 @@ def test_handle_called_with_queue_queue(self, mock_handle):
self.assertEqual(mock_handle.call_count, 5 * self.repeat,
'correct number of handled log messages')
- @support.requires_multiprocessing_queue
@patch.object(logging.handlers.QueueListener, 'handle')
def test_handle_called_with_mp_queue(self, mock_handle):
+ # Issue 28668: The multiprocessing (mp) module is not functional
+ # when the mp.synchronize module cannot be imported.
+ support.import_module('multiprocessing.synchronize')
for i in range(self.repeat):
log_queue = multiprocessing.Queue()
self.setup_and_log(log_queue, '%s_%s' % (self.id(), i))
@@ -3230,7 +3232,6 @@ def get_all_from_queue(log_queue):
except queue.Empty:
return []
- @support.requires_multiprocessing_queue
def test_no_messages_in_queue_after_stop(self):
"""
Five messages are logged then the QueueListener is stopped. This
@@ -3238,6 +3239,9 @@ def test_no_messages_in_queue_after_stop(self):
indicates that messages were not registered on the queue until
_after_ the QueueListener stopped.
"""
+ # Issue 28668: The multiprocessing (mp) module is not functional
+ # when the mp.synchronize module cannot be imported.
+ support.import_module('multiprocessing.synchronize')
for i in range(self.repeat):
queue = multiprocessing.Queue()
self.setup_and_log(queue, '%s_%s' %(self.id(), i))
diff --git a/Misc/NEWS.d/next/Tests/2017-11-25-14-53-29.bpo-28668.Y1G6pA.rst b/Misc/NEWS.d/next/Tests/2017-11-25-14-53-29.bpo-28668.Y1G6pA.rst
new file mode 100644
index 00000000000..e80516d984e
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2017-11-25-14-53-29.bpo-28668.Y1G6pA.rst
@@ -0,0 +1,3 @@
+test.support.requires_multiprocessing_queue is removed. Skip tests with
+test.support.import_module('multiprocessing.synchronize') instead when the
+semaphore implementation is broken or missing.
More information about the Python-checkins
mailing list