File: test_tr.py

package info (click to toggle)
qm 1.1.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,628 kB
  • ctags: 10,249
  • sloc: python: 41,482; ansic: 20,611; xml: 12,837; sh: 485; makefile: 226
file content (70 lines) | stat: -rw-r--r-- 1,543 bytes parent folder | download | duplicates (2)
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
from util import testAttribute
from util import error

def test():
	print 'testing source code syntax'
	from xml.dom.html import HTMLTableRowElement
	from xml.dom import implementation
	doc = implementation.createHTMLDocument('Title')
	r = doc.createElement('TR')

	#Row index and section row index tested in section

	print 'testing get/set'
	testAttribute(r,'bgColor');
	testAttribute(r,'ch');
	testAttribute(r,'chOff');
        r._set_align('left')
        rt = r._get_align()
        if rt != 'Left':
            error('get/set align failed')
        r._set_vAlign('top')
        rt = r._get_vAlign()
        if rt != 'Top':
            error('get/set align failed')
	print 'get/set works'

	print 'testing insertCell,deleteCell, getCells, and TD.cellIndex'

	try:
		c1 = r.insertCell(-1)
		error('insertCell(-1) does not raise exception')
	except:
		pass

	c1 = r.insertCell(0)
	if c1 == None:
		error('insertCell(0) failed');

	try:	
		c2 = r.insertCell(10)
		error('insertCell(10) does not raise exception')
	except:
		pass

	cells = r._get_cells()
	if cells._get_length() != 1:
		error('getCells failed');

	if cells.item(0).nodeName != c1.nodeName:
		error('getCells failed');

	try:
		r.deleteCell(-1);
		error('deleteCell(-1) does not raise exception');
	except:
		pass

	r.deleteCell(0);
	if c1._get_cellIndex() != -1:
		error('deleted cell still in tree');

	if r._get_cells().length != 0:
		error('deleteCell failed');

	print 'insertCell, deleteCell, getCells, and TD.getCellIndex works' 


if __name__ == '__main__':
	test();