File: test_processinginstruction.py

package info (click to toggle)
python-xml 0.8.4-10.1%2Blenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,972 kB
  • ctags: 10,628
  • sloc: python: 46,730; ansic: 14,354; xml: 968; makefile: 201; sh: 20
file content (47 lines) | stat: -rw-r--r-- 1,298 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from TestSuite import EMPTY_NAMESPACE
def test(tester):

    tester.startGroup('ProcessingInstruction')

    tester.startTest('Testing syntax')
    try:
        from xml.dom import ProcessingInstruction
        from xml.dom.ProcessingInstruction import ProcessingInstruction
    except:
        tester.error('Error in syntax', 1)
    tester.testDone()


    tester.startTest('Creating test environment')
    from xml.dom import implementation
    dt = implementation.createDocumentType('','','')
    doc = implementation.createDocument(EMPTY_NAMESPACE,'ROOT',dt)
    pi = doc.createProcessingInstruction("xml", 'version = "1.0"')
    tester.testDone()

    tester.startTest('Testing attributes')
    if pi.target != 'xml':
        tester.error('Problems with target')
    if pi.data != 'version = "1.0"':
        tester.error('Problems with data')
    tester.testDone()

    tester.startTest('Test cloneNode()')
    pi1 = pi.cloneNode(1)
    if pi1.target != pi.target:
        tester.error("cloneNode fails on target")
    if pi1.data != pi.data:
        tester.error("cloneNode fails on data")
    tester.testDone()


    return tester.groupDone()


if __name__ == '__main__':
    import sys
    import TestSuite

    tester = TestSuite.TestSuite()
    retVal = test(tester)
    sys.exit(retVal)