Example #1
0
 def testFileImportAtTopLevel(self):
     path = sibpath(__file__, "example3.coil")
     s = text.from_file(path)
     node = struct.StructNode(s)
     self.assertEquals(node.y.a, 2)
     self.assertEquals(node.y.b, 3)
     self.assertEquals(node.x, 1)
Example #2
0
 def testFileImport(self):
     path = sibpath(__file__, "example2.coil")
     s = text.from_file(path)
     node = struct.StructNode(s)
     # make sure relative and absolute paths work and are relative
     # to sub-struct that did the @file.
     self.assertEquals(node.sub.y.x, u"foo")
     self.assertEquals(node.sub.y.a2, u"bar")
     self.assertEquals(node.sub2.y.a2, 2) # 'a' didn't get overriden this time
Example #3
0
 def testFileSubImport(self):
     # @file can reference a sub-struct of imported file.
     s = text.from_file(sibpath(__file__, "filesubimport.coil"))
     node = struct.StructNode(s)
     # 0. Top-level import:
     self.assertEquals(node.imp.sub.x, "default")
     self.assertEquals(node.imp.sub.y, 2)
     self.assertEquals(node.imp.sub.two.parentx, "default")
     # 1. Single level sub-struct:
     self.assertEquals(node.sub.x, "foo")
     self.assertEquals(node.sub.y, 2)
     self.assertEquals(node.sub.two.parentx, "foo")
     # 2. Two level sub-struct:
     self.assertEquals(node.subsub.parentx, "bar")
     self.assertEquals(node.subsub.value, "hello")