Exemplo n.º 1
0
 def testTagNestingFix(self):
     result = collapseResultsWhitespace(htxpath.find(self.testData, "/html/span/b[!#class]"))
     wanted = ['<b>something <badly-nested-tag> <b class="fff"> </b> inside th ebadly nested tag </b>']
     self.assertEqual(result, wanted)
Exemplo n.º 2
0
 def testTagClosing(self):
     result = htxpath.find(self.testData, "/html/this-tag-is-open")
     result = htxpath.getAttributes(result[0])
     wanted = {'ourvalue': 'hooray!'}
     self.assertEqual(result, wanted)
Exemplo n.º 3
0
 def testAttributeExists(self):
     result = collapseResultsWhitespace(htxpath.find(self.testData, "//*[#value]"))
     wanted = ['<input type="help" value="OK4"/>', '<input type="help" value="OK4"/>', '<input type="help3" value="OK5" color="humorous"/>']
     self.assertEqual(result, wanted)
Exemplo n.º 4
0
 def testCDATAEscape(self):
     result = collapseResultsWhitespace(htxpath.find(self.testData, "/html/test"))
     wanted = ['<test id="test3"> hello &amp; my name is carol =5 &lt;test&gt; </test>']
     self.assertEqual(result, wanted)
Exemplo n.º 5
0
 def testAbsoluteSimplePathGetAttrs(self):
     result = htxpath.find(self.testData, "/html/body/span/input")
     result = htxpath.getAttributes(result[0])
     wanted = {'color': 'humorous', 'type': 'help3', 'value': 'OK5'}
     self.assertEqual(result, wanted)
Exemplo n.º 6
0
 def testWildcardAttribute(self):
     result = collapseResultsWhitespace(htxpath.find(self.testData, "//h1[*=super]"))
     wanted = ['<h1 class="super">OK</h1>', '<h1 id="super">OK</h1>', '<h1 lang="super">OK</h1>']
     self.assertEqual(result, wanted)
Exemplo n.º 7
0
 def testWildcardArgumentStartingPath(self):
     result = collapseResultsWhitespace(htxpath.find(self.testData, "//*[class^e]"))
     wanted = ['<div class="elo"> </div>', '<div-open class="eee"/>']
     self.assertEqual(result, wanted)
Exemplo n.º 8
0
 def testWildcardArgumentContainigPath(self):
     result = collapseResultsWhitespace(htxpath.find(self.testData, "//body/div[1]/*[class~ed]"))
     wanted = ['<div class="bed4"> <div class="bad"></div> <div class="red1"> <input type="help" value="OK4"/> </div> </div>']
     self.assertEqual(result, wanted)
Exemplo n.º 9
0
    def testBasicPath(self):
        result = collapseResultsWhitespace(htxpath.find(self.testData, "//body/div[id=d1]"))
        wanted = ['<div id="d1"> <a href="test test test">OK1</a><br/> <a id="5" class="jaunty" href="5aaa">OK2</a><br/> <a id="5" href="5bbb">OK3&4</a> <div class="bed4"> <div class="bad"></div> <div class="red1"> <input type="help" value="OK4"/> </div> </div> <div aclass="bed4"></div> </div>']

        self.assertEqual(result, wanted)