예제 #1
0
 def test_list(self):
     n = Node()
     n.append().set(1)
     self.assertTrue(n.child(0).value(), 1)
     # TODO: this needs to work but doesn't
     #self.assertTrue(n[0],1)
     n2 = Node()
     n2_c = n2.append()
     n2_c.set(2)
     self.assertEqual(n2.child(0).value(), 2)
예제 #2
0
 def test_list(self):
     n = Node()
     n.append().set(1)
     self.assertTrue(n.child(0).value(),1)
     # TODO: this needs to work but doesn't
     #self.assertTrue(n[0],1)
     n2 = Node()
     n2_c = n2.append()
     n2_c.set(2)
     self.assertEqual(n2.child(0).value(),2)
예제 #3
0
 def test_child(self):
     vec = array(range(100), uint32)
     n = Node()
     n['a'] = vec
     na = n.child(0)
     na_val = na.value()
     self.assertEqual(na_val[99], 99)
     n['b'] = vec
     self.assertEqual(n.number_of_children(), 2)
예제 #4
0
 def test_child(self):
     vec = array(range(100), uint32)
     n = Node()
     n['a'] = vec
     na = n.child(0)
     na_val = na.value()
     self.assertEqual(na_val[99], 99)
     n['b'] = vec
     self.assertEqual(n.number_of_children(),2)
 def test_key_with_slash(self):
     n = Node()
     n["normal/path"] = 10
     n.add_child("child_with_/_inside").set(42)
     print(n)
     self.assertTrue(n.has_path("normal/path"))
     self.assertFalse(n.has_child("normal/path"))
     self.assertFalse(n.has_path("child_with_/_inside"))
     self.assertTrue(n.has_child("child_with_/_inside"))
     self.assertEqual(2, n.number_of_children())
     self.assertEqual(n["normal/path"], 10)
     self.assertEqual(n.child(name="child_with_/_inside").value(), 42)
     n["normal"].remove_child("path")
     self.assertFalse(n.has_path("normal/path"))
예제 #6
0
    def test_list(self):
        n = Node()
        n.append().set(1)
        self.assertTrue(n.child(0).value(), 1)
        self.assertTrue(n[0], 1)
        n2 = Node()
        n2_c = n2.append()
        n2_c.set(2)
        self.assertEqual(n2.child(0).value(), 2)

        n3 = Node()
        n3.fetch("here").append().set("a")
        n3.fetch("here").append().set("b")
        self.assertTrue(n3.fetch("here").child(0).value(), "a")
        self.assertTrue(n3.fetch("here").child(1).value(), "b")

        n4 = Node()
        n4["here"].append().set("a")
        n5 = n4["here"]
        n5.append().set("b")
        self.assertTrue(n4["here"].child(0).value(), "a")
        self.assertTrue(n4["here"].child(1).value(), "b")
        self.assertTrue(n4["here"][0], "a")
        self.assertTrue(n4["here"][1], "b")