test_parent.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # License: BSD
00004 #   https://raw.github.com/robotics-in-concert/rocon_multimaster/license/LICENSE
00005 #
00006 ##############################################################################
00007 # Imports
00008 ##############################################################################
00009 
00010 from __future__ import print_function
00011 
00012 import roslaunch
00013 
00014 ##############################################################################
00015 # Test Launch Parent
00016 ##############################################################################
00017 
00018 
00019 class RoconTestLaunchParent(roslaunch.parent.ROSLaunchParent):
00020     '''
00021       Drop in replacement for ROSTestLaunchParent that lets us manage
00022       the run id ourselves.
00023     '''
00024 
00025     def __init__(self, run_id, config, roslaunch_files, port):
00026         if config is None:
00027             raise Exception("config not initialized")
00028         # DJS : I'm turning off the is_core flag here as we don't ever seem
00029         # to need it and it messes with things (usual parallel roslaunches
00030         # that start up their own masters do not use it, only roscore).
00031         super(RoconTestLaunchParent, self).__init__(run_id, roslaunch_files, is_core=False, port=port, is_rostest=True)
00032         self.config = config
00033 
00034     def _load_config(self):
00035         # disable super, just in case, though this shouldn't get called
00036         pass
00037 
00038     def setUp(self):
00039         """
00040         initializes self.config and xmlrpc infrastructure
00041         """
00042         self._start_infrastructure()
00043         self._init_runner()
00044 
00045     def tearDown(self):
00046         if self.runner is not None:
00047             runner = self.runner
00048             runner.stop()
00049         self._stop_infrastructure()
00050 
00051     def launch(self):
00052         """
00053         perform launch of nodes, does not launch tests.  rostest_parent
00054         follows a different pattern of init/run than the normal
00055         roslaunch, which is why it does not reuse start()/spin()
00056         """
00057         if self.runner is not None:
00058             return self.runner.launch()
00059         else:
00060             raise Exception("no runner to launch")
00061 
00062     def run_test(self, test):
00063         """
00064         run the test, blocks until completion
00065         """
00066         if self.runner is not None:
00067             # run the test, blocks until completion
00068             return self.runner.run_test(test)
00069         else:
00070             raise Exception("no runner")


rocon_test
Author(s): Daniel Stonier
autogenerated on Sat Jun 8 2019 18:48:47