Example #1
0
 def test_08_prop_list(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     props = p.properties().keys()
     self.assertEqual(props, ['deeper/test/path', 'there/now', 'here'])
Example #2
0
 def test_08_prop_list(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     props = p.properties().keys()
     self.assertEqual(props, ["deeper/test/path", "there/now", "here"])
Example #3
0
 def test_05_freeform_add(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     self.assertEqual(p.here, 3.0)
     self.assertEqual(p.there.now, 4.0)
     self.assertEqual(p.deeper.test.path, 5.0)
Example #4
0
 def test_05_freeform_add(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     self.assertEqual(p.here, 3.0)
     self.assertEqual(p.there.now, 4.0)
     self.assertEqual(p.deeper.test.path, 5.0)
Example #5
0
 def test_07_pickle(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     pstr = pickle.dumps(p)
     pres = pickle.loads(pstr)
     self.assertEqual(pres.here, 3.0)
     self.assertEqual(pres.there.now, 4.0)
     self.assertEqual(pres.deeper.test.path, 5.0)
Example #6
0
 def test_07_pickle(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     pstr = pickle.dumps(p)
     pres = pickle.loads(pstr)
     self.assertEqual(pres.here, 3.0)
     self.assertEqual(pres.there.now, 4.0)
     self.assertEqual(pres.deeper.test.path, 5.0)
Example #7
0
 def test_06_locking(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     p.lock()
     self.assertEqual(p.here, 3.0)
     self.assertEqual(p.there.now, 4.0)
     self.assertEqual(p.deeper.test.path, 5.0)
     self.assertRaises(AttributeError, p.__getitem__, "bad")
     self.assertRaises(AttributeError, p.__getitem__, "bad/deeper/path")
     self.assertRaises(AttributeError, p.__getattr__, "bad")
     self.assertRaises(AttributeError, p.there.__getattr__, "bad")
     self.assertEqual(p.deeper.test._locked, True)
Example #8
0
 def test_08_prop_list(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     props = list(p.properties().keys())
     # ordering may be different between python 2 and 3
     # sort to avoid issues comparing
     props.sort()
     self.assertEqual(props, [
         'deeper/test/path',
         'here',
         'there/now',
     ])
Example #9
0
 def test_06_locking(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     p.lock()
     self.assertEqual(p.here, 3.0)
     self.assertEqual(p.there.now, 4.0)
     self.assertEqual(p.deeper.test.path, 5.0)
     self.assertRaises(AttributeError, p.__getitem__, "bad")
     self.assertRaises(AttributeError, p.__getitem__, "bad/deeper/path")
     self.assertRaises(AttributeError, p.__getattr__, "bad")
     self.assertRaises(AttributeError, p.there.__getattr__, "bad")
     self.assertEqual(p.deeper.test._locked, True)
 def test_09_prop_update(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     props = p.properties().keys()
     p2 = PropertyTree()
     p2.value = True
     p2.last  = False
     p2.update(p)
     print p2
     props = p2.properties().keys()
     self.assertEqual(props,['deeper/test/path', 'there/now','last','value','here'])
     self.assertEqual(p2.value,True)
     self.assertEqual(p2.last,False)
     self.assertEqual(p2.here,3.0)
     self.assertEqual(p2.there.now,4.0)
     self.assertEqual(p2.deeper.test.path,5.0)
Example #11
0
 def test_09_prop_update(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     props = p.properties().keys()
     p2 = PropertyTree()
     p2.value = True
     p2.last = False
     p2.update(p)
     print p2
     props = p2.properties().keys()
     self.assertEqual(props, ["deeper/test/path", "there/now", "last", "value", "here"])
     self.assertEqual(p2.value, True)
     self.assertEqual(p2.last, False)
     self.assertEqual(p2.here, 3.0)
     self.assertEqual(p2.there.now, 4.0)
     self.assertEqual(p2.deeper.test.path, 5.0)
Example #12
0
 def test_09_prop_update(self):
     p = PropertyTree()
     p.here = 3.0
     p.there.now = 4.0
     p.deeper.test.path = 5.0
     props = list(p.properties().keys())
     p2 = PropertyTree()
     p2.value = True
     p2.last = False
     p2.update(p)
     print(p2)
     props = list(p2.properties().keys())
     # ordering may be different between python 2 and 3
     # sort to avoid issues comparing
     props.sort()
     self.assertEqual(
         props, ['deeper/test/path', 'here', 'last', 'there/now', 'value'])
     self.assertEqual(p2.value, True)
     self.assertEqual(p2.last, False)
     self.assertEqual(p2.here, 3.0)
     self.assertEqual(p2.there.now, 4.0)
     self.assertEqual(p2.deeper.test.path, 5.0)