def setup_module(): if not rostest_nose.is_rostest_enabled(): rostest_nose.rostest_nose_setup_module() # we still need a node to interact with topics rospy.init_node('TestStringTopic', anonymous=True, disable_signals=True)
def teardown_module(): if not rostest_nose.is_rostest_enabled(): # finishing all process are finished if pub_process is not None: pub_process.stop() if echo_process is not None: echo_process.stop() if slow_process is not None: slow_process.stop() rostest_nose.rostest_nose_teardown_module()
def test_rostest_detection(self): # check that pyros_utils/rostest_nose is usable even without delay import magic from pyros_utils import rostest_nose print("Checking rostest detection...") # checking detection works properly assert rostest_nose.is_rostest_enabled() # checking setup is done as expected # wait for the node to come up with timeout(5) as t: while not t.timed_out and not rosnode.rosnode_ping("string_pub_node", max_count=1): time.sleep(1) # TODO: improve this assert rosnode.rosnode_ping("string_pub_node", max_count=5)
def setup_module(): if not rostest_nose.is_rostest_enabled(): rostest_nose.rostest_nose_setup_module() # Start roslaunch launch = roslaunch.scriptapi.ROSLaunch() launch.start() # start required nodes - needs to match the content of *.test files for rostest to match global pub_process, echo_process, slow_process rospy.set_param('/echo_node/echo_service_name', 'test_service') echo_node = roslaunch.core.Node('pyros_test', 'echo.py', name='echo_node') try: echo_process = launch.launch(echo_node) except roslaunch.RLException as rlexc: logging.error( "pyros_test is needed to run this test. Please verify that it is installed in your ROS environment" ) raise rospy.set_param('/slow_node/slow_service_name', 'test_timeout_service') slow_node = roslaunch.core.Node('pyros_test', 'string_slow_node.py', name='slow_node') try: slow_process = launch.launch(slow_node) except roslaunch.RLException as rlexc: logging.error( "pyros_test is needed to run this test. Please verify that it is installed in your ROS environment" ) raise # set required parameters - needs to match the content of *.test files for rostest to match rospy.set_param('/stringServiceTest/echo_service_name', 'test_service') rospy.set_param('/stringServiceTest/slow_service_name', 'test_timeout_service') # we still need a node to interact with topics rospy.init_node('TestStringService', anonymous=True, disable_signals=True)
def setup_module(): if not rostest_nose.is_rostest_enabled(): rostest_nose.rostest_nose_setup_module() # Using pubs and subs require us to be a node rospy.init_node('test_publisher_if_pool', argv=None, disable_signals=True)
def teardown_module(): if not rostest_nose.is_rostest_enabled(): rostest_nose.rostest_nose_teardown_module()
def setup_module(): if not rostest_nose.is_rostest_enabled(): rostest_nose.rostest_nose_setup_module() # Providing services require us to be a node rospy.init_node('test_service_if_pool', argv=None, disable_signals=True)
# Tests Needed to validate that tests written for nose with pyros can also work with rostest # if called from usual rostest testCase def test_import_after_delay_setup_teardown_module(self): test_import_after_delay_setup_teardown_module() def test_import_before_delay_setup_teardown_module(self): test_import_before_delay_setup_teardown_module() if __name__ == '__main__': print("Running with ROStest if launched with rostest...") # testing rostest to validate rostests will still work. from pyros_utils import rostest_nose rostest_nose.rostest_or_nose_main('pyros_utils', 'testRosTest', testRosTest, sys.argv) if rostest_nose.is_rostest_enabled(): print("Force running with nose even if launched with rostest...") # Needed to validate that rostest_nose.rostest_or_nose_main will work fine if calling nose # we need to remove options that nose doesnt know #print(sys.argv) for opt in sys.argv[1:]: # we keep argv[0] if opt.startswith("--gtest_output") or opt.startswith("__name") or opt.startswith("__log") or opt.startswith("--text"): sys.argv.remove(opt) #print(sys.argv) rostest_nose.rostest_enabled = False # as well as nose nose.runmodule()
def setup_module(): if not rostest_nose.is_rostest_enabled(): rostest_nose.rostest_nose_setup_module()