예제 #1
0
def test_anonymous_name():
    from rosgraph.names import anonymous_name, is_legal_name
    val = anonymous_name('foo')
    assert 'foo' in val
    assert 'foo' != val
    assert val != anonymous_name('foo')
    assert not '/' in val
    assert is_legal_name(val)
예제 #2
0
파일: test_names.py 프로젝트: Aand1/ROSCH
def test_anonymous_name():
    from rosgraph.names import anonymous_name, is_legal_name
    val = anonymous_name('foo')
    assert 'foo' in val
    assert 'foo' != val
    assert val != anonymous_name('foo')
    assert not '/' in val
    assert is_legal_name(val)
예제 #3
0
 def _anonymous_name(self, name):
     try:
         from rosgraph.names import anonymous_name
         return anonymous_name(name)
     except ImportError:
         import random, socket, sys, warnings
         warnings.warn("Could not import the 'rosgraph' package; "
                       "resorting to fallback behaviour.")
         # Behaviour copied from rosgraph.names
         name = "{}_{}_{}_{}".format(name, socket.gethostname(),
                                     os.getpid(),
                                     random.randint(0, sys.maxsize))
         return name.replace('.', '_').replace('-', '_').replace(':', '_')