module documentation

Test cases related to XPath evaluation and the XPath class
Class ​ETree​ETXPath​Class​Test​Case Tests for the ETXPath class
Class ​ETree​XPath​Class​Test​Case Tests for the XPath class
Class ​ETree​XPath​Exslt​Test​Case Tests for the EXSLT support in XPath (requires libxslt 1.1.25+)
Class ​ETree​XPath​Test​Case XPath tests etree
Function args​Test1 Undocumented
Function args​Test2 Undocumented
Function boolean​Test Undocumented
Function float​Test Undocumented
Function result​Types​Test Undocumented
Function result​Types​Test2 Undocumented
Function set​Test Undocumented
Function set​Test2 Undocumented
Function string​List​Test Undocumented
Function string​Test 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):

Undocumented

def argsTest2(ctxt, st1, st2):

Undocumented

def booleanTest(ctxt, b1):

Undocumented

def floatTest(ctxt, f1):

Undocumented

def resultTypesTest(ctxt):

Undocumented

def resultTypesTest2(ctxt):

Undocumented

def setTest(ctxt, st1):

Undocumented

def setTest2(ctxt, st1):

Undocumented

def stringListTest(ctxt, s1):

Undocumented

def stringTest(ctxt, s1):

Undocumented

def tag(elem):

Undocumented

def tag_or_value(elem):

Undocumented

def test_suite():

Undocumented

def xpath():

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 =

Undocumented

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

Undocumented

uri: str =

Undocumented