class TestMPTimeout(PluginTester, unittest.TestCase): activate = '--processes=2' args = ['--process-timeout=1'] plugins = [MultiProcess()] suitepath = os.path.join(support, 'timeout.py') def runTest(self): assert "TimedOutException: 'timeout.test_timeout'" in self.output
def main(): from nose.plugins.multiprocess import MultiProcess with start_mzbench_server(): if not nose.run(defaultTest=[ __name__, 'mzb_signal_tests', 'mzb_negative_tests' ], addplugins=[MultiProcess()]): raise RuntimeError("some tests failed")
class TestMPNameError(PluginTester, unittest.TestCase): activate = '--processes=2' plugins = [MultiProcess()] suitepath = os.path.join(support, 'nameerror.py') def runTest(self): print str(self.output) assert 'NameError' in self.output assert "'undefined_variable' is not defined" in self.output
class MPTestBase(PluginTester, TestCase): processes = 1 activate = '--processes=1' plugins = [MultiProcess()] suitepath = os.path.join(support, 'timeout.py') def __init__(self, *args, **kwargs): self.activate = '--processes=%d' % self.processes PluginTester.__init__(self) TestCase.__init__(self, *args, **kwargs)
import os import sys import nose from nose.config import Config from nose.plugins.manager import PluginManager from nose.plugins.multiprocess import MultiProcess if __name__ == '__main__': if len(sys.argv) < 3: print "USAGE: %s TEST_FILE LOG_FILE KILL_FILE" % sys.argv[0] sys.exit(1) os.environ['NOSE_MP_LOG'] = sys.argv[2] os.environ['NOSE_MP_KILL'] = sys.argv[3] nose.main( defaultTest=sys.argv[1], argv=[sys.argv[0], '--processes=1', '-v'], config=Config(plugins=PluginManager(plugins=[MultiProcess()])))
# {'browserName': 'internet explorer', # 'version': '10', # 'platform': 'WIN8', # }, # {'browserName': 'internet explorer', # 'version': '9', # 'platform': 'VISTA', # } ] for platform in PLATFORMS: d = dict(SimpleSelTest.__dict__) name = "%s_%s_%s_%s" % (SimpleSelTest.__name__, platform['browserName'], platform.get('platform', 'ANY'), randint(0, 999)) name = name.replace(" ", "").replace(".", "") d.update({ '__test__': True, 'caps': platform, }) classes[name] = new.classobj(name, (SimpleSelTest, ), d) globals().update(classes) # this is just handy. If __main__, just run the tests in multiple processes if __name__ == "__main__": nose.core.run(argv=[ "nosetests", "-vv", "--processes", len(PLATFORMS), "--process-timeout", 180, __file__ ], plugins=[MultiProcess()]) #unittest.main()
import sys import nose import os import glob from nose.plugins import Plugin from nose.plugins.multiprocess import MultiProcess from nose.plugins.xunit import Xunit # http://nose.readthedocs.io/en/latest/doc_tests/test_multiprocess/multiprocess.html #from nose_xunitmp import XunitMP if __name__ == "__main__": args = [ "-v", "--with-xunit", "--xunit-file=results.xml", #"--with-xunitmp", #"--xunitmp-file=results.xml", "--processes=10", # parallel tests "--process-timeout=120" # parallel tests ] if sys.argv[1:]: args.extend(sys.argv[1:]) else: args.extend(glob.glob(os.path.join("tests", "*_test.py"))) nose.run(argv=args, plugins=[MultiProcess(), Xunit()]) #nose.run(argv=args, plugins=[MultiProcess(), XunitMP()])
def parse_arguments(): parser = argparse.ArgumentParser(description="Run the ElasticKube test suite.") parser.add_argument( "--processes", dest="processes", nargs="?", default=1, type=int, help="Run tests using up to N parallel processes" ) parser.add_argument( "--process-timeout", dest="timeout", nargs="?", default=10, type=int, help="Run tests with a timeout of N seconds per process" ) parser.add_argument("files", nargs="*") options, extras = parser.parse_known_args() if '-v' in extras: logging.getLogger().setLevel(logging.DEBUG) return options if __name__ == "__main__": nose.main(parse_arguments(), plugins=[MultiProcess()])