diff options
Diffstat (limited to 'unit_tests/test_multiprocess.py')
-rw-r--r-- | unit_tests/test_multiprocess.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/unit_tests/test_multiprocess.py b/unit_tests/test_multiprocess.py new file mode 100644 index 0000000..ec06ec9 --- /dev/null +++ b/unit_tests/test_multiprocess.py @@ -0,0 +1,55 @@ +import pickle +import sys +import unittest + +from nose import case +from nose.plugins import multiprocess +from nose.plugins.skip import SkipTest +from nose.config import Config +from nose.loader import TestLoader +try: + # 2.7+ + from unittest.runner import _WritelnDecorator +except ImportError: + from unittest import _WritelnDecorator + + +class ArgChecker: + def __init__(self, target, args): + self.target = target + self.args = args + # skip the id and queues + pargs = args[4:] + self.pickled = pickle.dumps(pargs) + def start(self): + pass + def is_alive(self): + return False + + +def setup(mod): + multiprocess._import_mp() + if not multiprocess.Process: + raise SkipTest("multiprocessing not available") + mod.Process = multiprocess.Process + multiprocess.Process = ArgChecker + + +class T(unittest.TestCase): + __test__ = False + def runTest(self): + pass + + +def test_mp_process_args_pickleable(): + test = case.Test(T('runTest')) + config = Config() + config.multiprocess_workers = 2 + config.multiprocess_timeout = 0.1 + runner = multiprocess.MultiProcessTestRunner( + stream=_WritelnDecorator(sys.stdout), + verbosity=2, + loaderClass=TestLoader, + config=config) + runner.run(test) + |