source: exist/trunk/python/elementtree-1.3a6-20070220-badc/unittests/test_find_fallback.py @ 3578

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/python/elementtree-1.3a6-20070220-badc/unittests/test_find_fallback.py@3578
Revision 3578, 1.0 KB checked in by pjkersha, 11 years ago (diff)

Latest releases from Fredrik Lundh. 10 March release has exclusive C14N support with namespace prefixes.

Line 
1# $Id: test_find_fallback.py 3356 2008-01-14 18:56:25Z fredrik $
2
3from support import *
4
5def setup():
6    # pretend the ElementPath module is not there
7    global OldElementPath
8    OldElementPath = ET.ElementPath
9    ET.ElementPath = ET._SimpleElementPath()
10
11def teardown():
12    ET.ElementPath = OldElementPath
13
14def simplefind():
15    """
16    Test find methods using the elementpath fallback.
17
18    >>> elem = SAMPLE_XML
19    >>> elem.find("tag").tag
20    'tag'
21    >>> ET.ElementTree(elem).find("tag").tag
22    'tag'
23    >>> elem.findtext("tag")
24    'text'
25    >>> elem.findtext("tog")
26    >>> elem.findtext("tog", "default")
27    'default'
28    >>> ET.ElementTree(elem).findtext("tag")
29    'text'
30    >>> summarize_list(elem.findall("tag"))
31    ['tag#1', 'tag#2']
32    >>> summarize_list(elem.findall(".//tag"))
33    ['tag#1', 'tag#2', 'tag#inner']
34
35    Path syntax doesn't work in this case.
36
37    >>> elem.find("section/tag")
38    >>> elem.findtext("section/tag")
39    >>> elem.findall("section/tag")
40    []
41
42    """
Note: See TracBrowser for help on using the repository browser.