41 from subprocess
import Popen, PIPE, check_call, call
51 sub = [
'args',
'info',
'list',
'call',
'type',
'uri',
'find']
53 output = Popen([cmd], stdout=PIPE).communicate()[0]
54 output = output.decode()
55 self.assert_(
'Commands' in output)
56 output = Popen([cmd,
'-h'], stdout=PIPE).communicate()[0]
57 output = output.decode()
58 self.assert_(
'Commands' in output)
61 self.assert_(
"%s %s"%(cmd, c)
in output, output)
64 output = Popen([cmd, c,
'-h'], stdout=PIPE).communicate()
65 self.assert_(
"Usage:" in output[0].decode(), output)
67 self.assert_(
"%s %s" % (cmd, c)
in output[0].decode(), output)
73 env = os.environ.copy()
74 env[
'ROS_MASTER_URI'] =
'http://localhost:11312' 75 kwds = {
'env': env,
'stdout': PIPE,
'stderr': PIPE}
77 msg =
"ERROR: Unable to communicate with master!\n" 79 output = Popen([cmd,
'list'], **kwds).communicate()
80 self.assert_(output[1].decode().endswith(msg))
81 output = Popen([cmd,
'type',
'add_two_ints'], **kwds).communicate()
82 self.assert_(output[1].decode().endswith(msg))
83 output = Popen([cmd,
'uri',
'add_two_ints'], **kwds).communicate()
84 self.assert_(output[1].decode().endswith(msg))
85 output = Popen([cmd,
'call',
'add_two_ints',
'1',
'2'], **kwds).communicate()
86 self.assert_(output[1].decode().endswith(msg))
88 output = Popen([cmd,
'call',
'--wait',
'add_two_ints',
'1',
'2'], **kwds).communicate()
89 self.assert_(output[1].decode().endswith(msg))
90 output = Popen([cmd,
'find',
'test_ros/AddTwoInts'], **kwds).communicate()
91 self.assert_(output[1].decode().endswith(msg))
93 if __name__ ==
'__main__':
94 rostest.unitrun(
'test_rosservice', NAME, TestRosserviceOffline, sys.argv, coverage_packages=[])
def test_cmd_help(self)
test that the usage command works