module documentation

Test cases related to XPath evaluation and the XPath class

Class ETreeETXPathClassTestCase Tests for the ETXPath class
Class ETreeXPathClassTestCase Tests for the XPath class
Class ETreeXPathExsltTestCase Tests for the EXSLT support in XPath (requires libxslt 1.1.25+)
Class ETreeXPathTestCase XPath tests etree
Function argsTest1 Undocumented
Function argsTest2 Undocumented
Function booleanTest Undocumented
Function floatTest Undocumented
Function resultTypesTest Undocumented
Function resultTypesTest2 Undocumented
Function setTest Undocumented
Function setTest2 Undocumented
Function stringListTest Undocumented
Function stringTest Undocumented
Function tag Undocumented
Function tag_or_value Undocumented
Function test_suite Undocumented
Function xpath Test xpath extension functions.
Constant SAMPLE_XML Undocumented
Variable extension Undocumented
Variable uri Undocumented
def argsTest1(ctxt, s, f, b, st): (source)

Undocumented

def argsTest2(ctxt, st1, st2): (source)

Undocumented

def booleanTest(ctxt, b1): (source)

Undocumented

def floatTest(ctxt, f1): (source)

Undocumented

def resultTypesTest(ctxt): (source)

Undocumented

def resultTypesTest2(ctxt): (source)

Undocumented

def setTest(ctxt, st1): (source)

Undocumented

def setTest2(ctxt, st1): (source)

Undocumented

def stringListTest(ctxt, s1): (source)

Undocumented

def stringTest(ctxt, s1): (source)

Undocumented

def tag(elem): (source)

Undocumented

def tag_or_value(elem): (source)

Undocumented

def test_suite(): (source)

Undocumented

def xpath(): (source)

Test xpath extension functions. >>> root = SAMPLE_XML >>> e = etree.XPathEvaluator(root, extensions=[extension]) >>> e("stringTest('you')") 'Hello you' >>> e(_bytes("stringTest('\\xe9lan')").decode("unicode_escape")) u'Hello \xe9lan' >>> e("stringTest('you','there')") #doctest: +ELLIPSIS Traceback (most recent call last): ... TypeError: stringTest() takes... 2 ...arguments ... >>> e("floatTest(2)") 6.0 >>> e("booleanTest(true())") False >>> list(map(tag, e("setTest(/body/tag)"))) ['tag'] >>> list(map(tag, e("setTest2(/body/*)"))) ['tag', 'section'] >>> list(map(tag_or_value, e("stringListTest(/body/tag)"))) ['Hello ', 'tag', 'tag', 'tag', '!'] >>> e("argsTest1('a',1.5,true(),/body/tag)") "a, 1.5, True, ['tag', 'tag', 'tag']" >>> list(map(tag, e("argsTest2(/body/tag, /body/section)"))) ['tag', 'section', 'tag', 'tag'] >>> e("resultTypesTest()") Traceback (most recent call last): ... XPathResultError: This is not a supported node-set result: None >>> try: ... e("resultTypesTest2()") ... except etree.XPathResultError: ... print("Got error") Got error

SAMPLE_XML = (source)

Undocumented

Value
etree.parse(BytesIO('''
<body>
  <tag>text</tag>
  <section>
    <tag>subtext</tag>
  </section>
  <tag />
...
extension = (source)

Undocumented

Undocumented