diff options
author | Charles-François Natali <neologix@free.fr> | 2011-09-20 18:36:51 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-09-20 18:36:51 (GMT) |
commit | bc8f08216e2cea53f5c2650f60d3e943a9e48efb (patch) | |
tree | f38e949d776b72e003396a2e1baa88ec86f7b193 | |
parent | 225aa4f8ec1d98a244f863ee5257a750926a494e (diff) | |
download | cpython-bc8f08216e2cea53f5c2650f60d3e943a9e48efb.zip cpython-bc8f08216e2cea53f5c2650f60d3e943a9e48efb.tar.gz cpython-bc8f08216e2cea53f5c2650f60d3e943a9e48efb.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).
-rw-r--r-- | Lib/test/test_multiprocessing.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 3f8a9a2..7ac77e9 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 @@ -1631,6 +1637,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") @@ -1648,6 +1655,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, @@ -1987,10 +1995,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') |