PageRenderTime 916ms CodeModel.GetById 18ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 892ms

/functional_tests/test_multiprocessing/test_process_timeout.py

https://bitbucket.org/jpellerin/nose/
Python | 37 lines | 26 code | 11 blank | 0 comment | 5 complexity | b7cebbb3851e65ee5b73491f0dd82e3c MD5 | raw file
 1import os
 2import unittest
 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
10
11def setup():
12    try:
13        import multiprocessing
14        if 'active' in MultiProcess.status:
15            raise SkipTest("Multiprocess plugin is active. Skipping tests of "
16                           "plugin itself.")
17    except ImportError:
18        raise SkipTest("multiprocessing module not available")
19
20
21
22class TestMPTimeout(PluginTester, unittest.TestCase):
23    activate = '--processes=2'
24    args = ['--process-timeout=1']
25    plugins = [MultiProcess()]
26    suitepath = os.path.join(support, 'timeout.py')
27
28    def runTest(self):
29        assert "TimedOutException: 'timeout.test_timeout'" in self.output
30
31
32class TestMPTimeoutPass(TestMPTimeout):
33    args = ['--process-timeout=3']
34
35    def runTest(self):
36        assert "TimedOutException: 'timeout.test_timeout'" not in self.output
37        assert str(self.output).strip().endswith('OK')