/functional_tests/test_multiprocessing/test_process_timeout.py

https://bitbucket.org/jpellerin/nose/ · Python · 37 lines · 26 code · 11 blank · 0 comment · 3 complexity · b7cebbb3851e65ee5b73491f0dd82e3c MD5 · raw file

  1. import os
  2. import unittest
  3. from nose.plugins import PluginTester
  4. from nose.plugins.skip import SkipTest
  5. from nose.plugins.multiprocess import MultiProcess
  6. support = os.path.join(os.path.dirname(__file__), 'support')
  7. def setup():
  8. try:
  9. import multiprocessing
  10. if 'active' in MultiProcess.status:
  11. raise SkipTest("Multiprocess plugin is active. Skipping tests of "
  12. "plugin itself.")
  13. except ImportError:
  14. raise SkipTest("multiprocessing module not available")
  15. class TestMPTimeout(PluginTester, unittest.TestCase):
  16. activate = '--processes=2'
  17. args = ['--process-timeout=1']
  18. plugins = [MultiProcess()]
  19. suitepath = os.path.join(support, 'timeout.py')
  20. def runTest(self):
  21. assert "TimedOutException: 'timeout.test_timeout'" in self.output
  22. class TestMPTimeoutPass(TestMPTimeout):
  23. args = ['--process-timeout=3']
  24. def runTest(self):
  25. assert "TimedOutException: 'timeout.test_timeout'" not in self.output
  26. assert str(self.output).strip().endswith('OK')