diff options
author | Charles-François Natali <neologix@free.fr> | 2011-09-21 16:48:21 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-09-21 16:48:21 (GMT) |
commit | e51c8dad1a086d2d7cd2b343c625805fa7a856bd (patch) | |
tree | bbfeca70429db8df032bfa42e01f0a2f9c9837e6 /Lib | |
parent | 4507e6456e6170f92e14d7ecb68f2617a3b48412 (diff) | |
download | cpython-e51c8dad1a086d2d7cd2b343c625805fa7a856bd.zip cpython-e51c8dad1a086d2d7cd2b343c625805fa7a856bd.tar.gz cpython-e51c8dad1a086d2d7cd2b343c625805fa7a856bd.tar.bz2 |
Issue #12981: test_multiprocessing: catch ImportError when importing
multiprocessing.reduction, which may not be available (e.g. if the OS doesn't
support FD passing over Unix domain sockets).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_multiprocessing.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 1d84ca8..6940d0e 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -35,7 +35,13 @@ import multiprocessing.managers import multiprocessing.heap import multiprocessing.pool -from multiprocessing import util, reduction +from multiprocessing import util + +try: + from multiprocessing import reduction + HAS_REDUCTION = True +except ImportError: + HAS_REDUCTION = False try: from multiprocessing.sharedctypes import Value, copy @@ -1582,6 +1588,7 @@ class _TestConnection(BaseTestCase): os.write(fd, data) os.close(fd) + @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction") def test_fd_transfer(self): if self.TYPE != 'processes': self.skipTest("only makes sense with processes") @@ -1600,6 +1607,7 @@ class _TestConnection(BaseTestCase): with open(test.support.TESTFN, "rb") as f: self.assertEqual(f.read(), b"foo") + @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction") @unittest.skipIf(sys.platform == "win32", "test semantics don't make sense on Windows") @unittest.skipIf(MAXFD <= 256, @@ -1636,6 +1644,7 @@ class _TestConnection(BaseTestCase): def _send_data_without_fd(self, conn): os.write(conn.fileno(), b"\0") + @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction") @unittest.skipIf(sys.platform == "win32", "doesn't make sense on Windows") def test_missing_fd_transfer(self): # Check that exception is raised when received data is not @@ -1957,10 +1966,12 @@ class _TestImportStar(BaseTestCase): 'multiprocessing', 'multiprocessing.connection', 'multiprocessing.heap', 'multiprocessing.managers', 'multiprocessing.pool', 'multiprocessing.process', - 'multiprocessing.reduction', 'multiprocessing.synchronize', 'multiprocessing.util' ] + if HAS_REDUCTION: + modules.append('multiprocessing.reduction') + if c_int is not None: # This module requires _ctypes modules.append('multiprocessing.sharedctypes') |