test_config_parser.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 PKG = 'ez_interactive_marker'
3 import roslib; roslib.load_manifest(PKG)
4 import unittest
5 import tempfile
6 import numpy as np
8 
9 class TestConfigParser(unittest.TestCase):
10  def test_load_include(self):
11  tpf = tempfile.NamedTemporaryFile()
12  f = open(tpf.name, 'w')
13  f.write('{"test": 1}')
14  f.close()
15  src = '{value: !include %s}' % tpf.name
16  dst = ec.yaml.load(src)
17  self.assertEqual(dst['value'], {'test': 1})
18 
19  def test_load_enum(self):
20  src = '{value: !enum [visualization_msgs/Marker, CUBE]}'
21  dst = ec.yaml.load(src)
22  self.assertEqual(dst['value'], 1)
23 
24  def test_load_degrees(self):
25  src = '{value: !degrees 180.0}'
26  dst = ec.yaml.load(src)
27  self.assertAlmostEqual(dst['value'], np.pi)
28 
29  def test_load_euler(self):
30  src = '{value: !euler [0.0, 0.0, 0.0]}'
31  dst = ec.yaml.load(src)
32  self.assertAlmostEqual(dst['value']['x'], 0.0)
33  self.assertAlmostEqual(dst['value']['y'], 0.0)
34  self.assertAlmostEqual(dst['value']['z'], 0.0)
35  self.assertAlmostEqual(dst['value']['w'], 1.0)
36 
37 if __name__ == '__main__':
38  import rostest
39  rostest.rosrun(PKG, 'test_config_parser', TestConfigParser)


ez_interactive_marker
Author(s):
autogenerated on Mon Jun 10 2019 13:15:06