예제 #1
0
    def test_init(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateIndexedNode()
        self.assertIsNotNone(node)

        root.append(node)
        self.assertEqual(len(root.children), 1)
예제 #2
0
    def test_get_set(self):
        node = TemplateIndexedNode()
        node.position = 3
        self.assertEqual(3, node.position)
        node.position = 4
        self.assertEqual(4, node.position)

        node.index = 3
        self.assertEqual(3, node.index)
        node.index = 4
        self.assertEqual(4, node.index)
예제 #3
0
 def test_invalid_attrib_name(self):
     with self.assertRaises(Exception):
         node = TemplateIndexedNode()
         node.set_attrib('rubbish', 3)
예제 #4
0
 def test_attrib_name_index_only(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', 3)
     self.assertEqual(3, node.index)
예제 #5
0
 def __init__(self, index=1):
     TemplateIndexedNode.__init__(self, index)
예제 #6
0
 def __init__(self, position=1, index=1):
     TemplateIndexedNode.__init__(self, position, index)
예제 #7
0
    def test_attrib_name_position_and_index_invalid(self):
        node = TemplateIndexedNode()

        with self.assertRaises(ParserException):
            node.set_attrib('index', "1 3")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "0,1")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "1,0")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "0,0")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "1,x")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "x,1")

        with self.assertRaises(ParserException):
            node.set_attrib('index', "x,x")
예제 #8
0
 def test_attrib_name_index_only(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', 3)
     self.assertEqual(3, node.index)
예제 #9
0
    def test_invalid_index_value(self):
        node = TemplateIndexedNode()

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("x"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("x, 1"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("1, x"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("x, x"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("*, 1"))

        with self.assertRaises(ParserException):
            node.set_attrib("index", TemplateWordNode("1, 2, 3"))
예제 #10
0
 def test_attrib_name_index_only(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', TemplateWordNode("3"))
     self.assertEqual("3", node.index.word)
예제 #11
0
    def test_valid_index_value(self):
        node = TemplateIndexedNode()

        node.set_attrib("index", TemplateWordNode("1"))

        node.set_attrib("index", TemplateWordNode("1, 2"))

        node.set_attrib("index", "1")

        node.set_attrib("index", "1, 2")

        node.set_attrib("index", "1, *")
예제 #12
0
 def test_get_set(self):
     node = TemplateIndexedNode()
     node.index = 3
     self.assertEqual("3", node.index.word)
     node.index = 4
     self.assertEqual("4", node.index.word)
예제 #13
0
 def test_resolve(self):
     node = TemplateIndexedNode()
     with self.assertRaises(NotImplementedError):
         node.resolve_to_string(None)
예제 #14
0
 def test_invalid_attrib_name(self):
     with self.assertRaises(Exception):
         node = TemplateIndexedNode()
         node.set_attrib('rubbish', 3)
예제 #15
0
파일: star.py 프로젝트: ystanwar/program-y
 def __init__(self, position=1, index=1):
     TemplateIndexedNode.__init__(self, position, index)
예제 #16
0
 def test_attrib_name_position_and_index_as_star(self):
     node = TemplateIndexedNode()
     node.set_attrib('index', "1,*")
     self.assertEqual(1, node.position)
     self.assertEqual(1, node.index)
예제 #17
0
 def __init__(self, index=1):
     TemplateIndexedNode.__init__(self, index)
예제 #18
0
 def test_get_set(self):
     node = TemplateIndexedNode()
     node.index = 3
     self.assertEqual(3, node.index)
     node.index = 4
     self.assertEqual(4, node.index)