File: test_section.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 (77 lines) | stat: -rw-r--r-- 1,867 bytes parent folder | download | duplicates (3)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from util import testAttribute
from util import error

def test():
    print 'testing source code syntax'
    from xml.dom.html import HTMLTableSectionElement
    from xml.dom import implementation
    doc = implementation.createHTMLDocument('Title')
    s = doc.createElement('TFOOT')

    #Row index and section row index tested in section
    print 'testing get/set'
    testAttribute(s,'ch')
    testAttribute(s,'chOff')

    s._set_align('left')
    rt = s._get_align()
    if rt != 'Left':
        error('get/set align failed')
    s._set_vAlign('Top')
    rt = s._get_vAlign()
    if rt != 'Top':
        error('get/set align failed')

    print 'get/set works'

    print 'testing insertRow,deleteRow, getRows, and TR.getRowSelectionIndex'

    try:
        r1 = s.insertRow(-1)
        error('insertRow(-1) does not raise exception');
    except:
        pass

    r1 = s.insertRow(0)
    if r1 == None:
        error('insertRow(0) failed');

    r2 = s.insertRow(1)
    if r2 == None:
        error('insertRow(1) failed');

    if r2._get_sectionRowIndex() != 1:
        error('getSectionRowIndex Failed');

    rows = s._get_rows()
    if rows._get_length() != 2:
        error('getRows failed')

    if rows.item(0).nodeName != r1.nodeName:
        error('getRows failed')

    if rows.item(1).nodeName != r2.nodeName:
        error('getRows failed')

    try:
        s.deleteRow(-1)
        error('deleteRow(-1) does not raise exception')
    except:
        pass

    s.deleteRow(1)
    if r2._get_rowIndex() != -1:
        error('deleted row still in tree')

    if s._get_rows()._get_length() != 1:
        error('deleteRow failed');

    s.deleteRow(0)
    if s._get_rows()._get_length() != 0:
        error('deleteRow(0) failed')

    print 'insertRow, deleteRow, getRows, and TR.getSelectionRowIndex works'


if __name__ == '__main__':
    test()