1import os
2from unittest import TestCase
3
4from nose.plugins import PluginTester
5from nose.plugins.skip import SkipTest
6from nose.plugins.multiprocess import MultiProcess
7
8support = os.path.join(os.path.dirname(__file__), 'support')
9
10def setup():
11    try:
12        import multiprocessing
13        if 'active' in MultiProcess.status:
14            raise SkipTest("Multiprocess plugin is active. Skipping tests of "
15                           "plugin itself.")
16    except ImportError:
17        raise SkipTest("multiprocessing module not available")
18
19class MPTestBase(PluginTester, TestCase):
20    processes = 1
21    activate = '--processes=1'
22    plugins = [MultiProcess()]
23    suitepath = os.path.join(support, 'timeout.py')
24
25    def __init__(self, *args, **kwargs):
26        self.activate = '--processes=%d' % self.processes
27        PluginTester.__init__(self)
28        TestCase.__init__(self, *args, **kwargs)
29