예제 #1
0
    def test_resolve_macro(self):
        # define three nested macro dicts with the same macro names (keys)
        content = {'simple': 'simple'}
        ns2 = dict({k: v+'2' for k,v in content.items()})
        ns1 = dict({k: v+'1' for k,v in content.items()})
        ns1.update(ns2=ns2)
        macros = dict(content)
        macros.update(ns1=ns1)

        self.assertEqual(xacro.resolve_macro('simple', macros), 'simple')
        self.assertEqual(xacro.resolve_macro('ns1.simple', macros), 'simple1')
        self.assertEqual(xacro.resolve_macro('ns1.ns2.simple', macros), 'simple2')
예제 #2
0
    def test_resolve_macro(self):
        # define three nested macro dicts with the same macro names (keys)
        content = {'xacro:simple': 'simple'}
        ns2 = dict({k: v+'2' for k,v in content.iteritems()})
        ns1 = dict({k: v+'1' for k,v in content.iteritems()})
        ns1.update(ns2=ns2)
        macros = dict(content)
        macros.update(ns1=ns1)

        self.assertEqual(xacro.resolve_macro('simple', macros), 'simple')
        self.assertEqual(xacro.resolve_macro('ns1.simple', macros), 'simple1')
        self.assertEqual(xacro.resolve_macro('ns1.ns2.simple', macros), 'simple2')

        self.assertEqual(xacro.resolve_macro('xacro:simple', macros), 'simple')
        self.assertEqual(xacro.resolve_macro('xacro:ns1.simple', macros), 'simple1')
        self.assertEqual(xacro.resolve_macro('xacro:ns1.ns2.simple', macros), 'simple2')
예제 #3
0
    def test_resolve_macro(self):
        # define three nested macro dicts with the same content
        content = {'simple': 'simple', 'xacro:prefixed': 'prefixed'}
        ns2 = dict({k: v+'2' for k,v in content.iteritems()})
        ns1 = dict({k: v+'1' for k,v in content.iteritems()})
        ns1.update(ns2=ns2)
        macros = dict(content)
        macros.update(ns1=ns1)

        self.assertEqual(xacro.resolve_macro('simple', macros), 'simple')
        self.assertEqual(xacro.resolve_macro('ns1.simple', macros), 'simple1')
        self.assertEqual(xacro.resolve_macro('ns1.ns2.simple', macros), 'simple2')

        self.assertEqual(xacro.resolve_macro('xacro:simple', macros), 'simple')
        self.assertEqual(xacro.resolve_macro('xacro:ns1.simple', macros), 'simple1')
        self.assertEqual(xacro.resolve_macro('xacro:ns1.ns2.simple', macros), 'simple2')

        self.assertEqual(xacro.resolve_macro('prefixed', macros), None)
        self.assertEqual(xacro.resolve_macro('ns1.prefixed', macros), None)
        self.assertEqual(xacro.resolve_macro('ns1.ns2.prefixed', macros), None)

        self.assertEqual(xacro.resolve_macro('xacro:prefixed', macros), 'prefixed')
        self.assertEqual(xacro.resolve_macro('xacro:ns1.prefixed', macros), 'prefixed1')
        self.assertEqual(xacro.resolve_macro('xacro:ns1.ns2.prefixed', macros), 'prefixed2')