示例#1
0
文件: test_tpl.py 项目: pastebt/yeast
 def _test_id1(self, h):
     self.setup()
     self.mp.feed(h)
     ret = tpl.select('#a', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0]['id'], 'a')
     ret = tpl.select('#b', self.func)
     self.assertEqual(ret, [])
示例#2
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_disabled2(self):
     self.setup()
     self.mp.feed("<a><input name='who' />a</a>")
     ret = tpl.select(':disabled', self.func)
     self.assertEqual(len(ret), 0)
     ret = tpl.select(':enabled', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0]['name'], 'who')
示例#3
0
文件: test_tpl.py 项目: pastebt/yeast
 def _test_class1(self, h):
     self.setup()
     #h = "<a> </a>"
     self.mp.feed(h)
     ret = tpl.select('.a', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0].tag, 'a')
     self.assertEqual(ret[0]['class'], 'a')
     ret = tpl.select('.b', self.func)
     self.assertEqual(ret, [])
示例#4
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_group1(self):
     self.setup()
     self.mp.feed("<a>a</a><b>b</b>")
     ret = tpl.select('b,a', self.func)
     self.assertEqual(len(ret), 2)
     self.assertEqual(ret[0].tag, 'b')
     self.assertEqual(ret[1].tag, 'a')
     ret = tpl.select('a,b', self.func)
     self.assertEqual(len(ret), 2)
     self.assertEqual(ret[1].tag, 'b')
     self.assertEqual(ret[0].tag, 'a')
示例#5
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_class3(self):
     self.setup()
     h = "<a class='cd a' b='2'> </a>"
     self.mp.feed(h)
     ret = tpl.select('.a', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0].tag, 'a')
     self.assertEqual(ret[0]['class'], 'cd a')
     ret = tpl.select('.b', self.func)
     self.assertEqual(ret, [])
示例#6
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_tag2(self):
     self.setup()
     h = "<html><a b='1'> </a><div/><a b='2'> <br/></a></html>"
     self.mp.feed(h)
     ret = tpl.select('a', self.func)
     self.assertEqual(len(ret), 2)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertTrue(isinstance(ret[1], tpl.TagNode))
     self.assertEqual((ret[0].tag, ret[1].tag), ('a', 'a'))
     self.assertEqual((ret[0]['b'], ret[1]['b']), ('1', '2'))
     ret = tpl.select('b', self.func)
     self.assertEqual(ret, [])
示例#7
0
文件: test_tpl.py 项目: pastebt/yeast
 def _test_indirect_child1(self, h):
     self.setup()
     self.mp.feed(h)
     ret = tpl.select('a b', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0].tag, 'b')
示例#8
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_checked2(self):
     self.setup()
     self.mp.feed("<a><input type='radio' checked name='who' />a</a>")
     ret = tpl.select(':checked', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0]['name'], 'who')
示例#9
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_first_child2(self):
     self.setup()
     self.mp.feed("<a><b id='b'>b</b>a<b id='c'></b></a>")
     ret = tpl.select('b:first-child', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0].tag, 'b')
     self.assertEqual(ret[0]['id'], 'b')
示例#10
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_attribute_eq5(self):
     self.setup()
     self.mp.feed(" <a abcd='1'> <b abcd='2 3'> abccc </b> </a>")
     ret = tpl.select('a  [abcd="2 3"]', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0]['abcd'], '2 3')
     self.assertEqual(ret[0].tag, 'b')
示例#11
0
文件: test_tpl.py 项目: pastebt/yeast
    def test_attribute_in1(self):
        self.setup()
        self.mp.feed("<a abcd='efgh'></a><b abcd></b>")
        ret = tpl.select('[abcd*=ef]', self.func)
        self.assertEqual(len(ret), 1)
        t = ret[0]
        self.assertTrue(isinstance(t, tpl.TagNode))
        self.assertEqual(t['abcd'], 'efgh')
        self.assertEqual(t.tag, 'a')

        ret = tpl.select('[abcd*=fg]', self.func)
        self.assertEqual(len(ret), 1)
        self.assertEqual(ret[0], t)

        ret = tpl.select('[abcd*=gh]', self.func)
        self.assertEqual(len(ret), 1)
        self.assertEqual(ret[0], t)
示例#12
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_attribute_ed1(self):
     self.setup()
     self.mp.feed("<a abcd='efgh'></a><b abcd></b>")
     ret = tpl.select('[abcd$=gh]', self.func)
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0]['abcd'], 'efgh')
     self.assertEqual(ret[0].tag, 'a')
示例#13
0
文件: test_tpl.py 项目: pastebt/yeast
 def _test_direct_child1(self, h):
     self.setup()
     self.mp.feed(h)
     ret = tpl.select('a>b', self.func)
     #print ret, str(ret[0])
     self.assertEqual(len(ret), 1)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0].tag, 'b')
     self.assertEqual(ret[0].parent.tag, 'a')
示例#14
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_first_child1(self):
     self.setup()
     self.mp.feed("<a>a</a><b>b</b>")
     ret = tpl.select(':first-child', self.func)
     self.assertEqual(len(ret), 3)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0].tag, 'a')
     self.assertTrue(isinstance(ret[1], tpl.DataNode))
     self.assertEqual(str(ret[1]), 'a')
     self.assertTrue(isinstance(ret[2], tpl.DataNode))
     self.assertEqual(str(ret[2]), 'b')
示例#15
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_attribute1(self):
     self.setup()
     self.mp.feed("<a abcd='1'></a><b abcd></b>")
     ret = tpl.select('[abcd]', self.func)
     self.assertEqual(len(ret), 2)
     self.assertTrue(isinstance(ret[0], tpl.TagNode))
     self.assertEqual(ret[0]['abcd'], '1')
     self.assertEqual(ret[0].tag, 'a')
     self.assertTrue(isinstance(ret[1], tpl.TagNode))
     self.assertTrue(ret[1]['abcd'] is None)
     self.assertEqual(ret[1].tag, 'b')
示例#16
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_attribute_ed2(self):
     self.setup()
     self.mp.feed("<a abcd='efgh'></a><b abcd></b>")
     ret = tpl.select('[abcd^=fg]', self.func)
     self.assertEqual(len(ret), 0)
示例#17
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_id2(self):
     self.setup()
     self.mp.feed("<a id='b' b='2'> </a>")
     ret = tpl.select('#a', self.func)
     self.assertEqual(ret, [])
示例#18
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_direct_child2(self):
     self.setup()
     self.mp.feed("<a>a<c>c<b>b</b></c></a>")
     ret = tpl.select('a>b', self.func)
     self.assertEqual(len(ret), 0)
示例#19
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_group2(self):
     self.setup()
     self.mp.feed("<a>a</a><b>b</b>")
     ret = tpl.select('b , a', self.func)
     self.assertEqual(len(ret), 2)
示例#20
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_first_child3(self):
     self.setup()
     self.mp.feed("<a>a<b id='b'>b</b>a<b id='c'></b></a>")
     ret = tpl.select('b:first-child', self.func)
     self.assertEqual(len(ret), 0)
示例#21
0
文件: test_tpl.py 项目: pastebt/yeast
 def test_checked4(self):
     self.setup()
     self.mp.feed("<a><input checked name='who' />a</a>")
     ret = tpl.select(':checked', self.func)
     self.assertEqual(len(ret), 0)