Esempio n. 1
0
    def test_get_host_name(self):
        from rosgraph.network import get_host_name

        os.environ['ROS_IP'] = 'foo'
        assert 'foo' == get_host_name()
        os.environ['ROS_HOSTNAME'] = 'bar'
        assert 'bar' == get_host_name()

        try:
            real_argv = sys.argv[:]
            sys.argv = real_argv[:] + ['__ip:=1.2.3.4']
            assert '1.2.3.4' == get_host_name()
            sys.argv = real_argv[:] + ['__hostname:=baz']
            assert 'baz' == get_host_name()
        finally:
            sys.argv = real_argv
 def test_get_host_name(self):
     from rosgraph.network import get_host_name
     
     os.environ['ROS_IP'] = 'foo'
     assert 'foo' == get_host_name()
     os.environ['ROS_HOSTNAME'] = 'bar'
     assert 'bar' == get_host_name()
 
     try:
         real_argv = sys.argv[:]
         sys.argv = real_argv[:] + ['__ip:=1.2.3.4']
         assert '1.2.3.4' == get_host_name()
         sys.argv = real_argv[:] + ['__hostname:=baz']      
         assert 'baz' == get_host_name()
     finally:
       sys.argv = real_argv