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
|
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - MoinMoin.widget.html Tests
@copyright: 2003-2004 by Juergen Hermann <jh@web.de>
@license: GNU GPL, see COPYING for details.
"""
import py
from MoinMoin.widget import html
class TestHTMLWidgets:
"""widget.html: testing html widgets"""
def testCreate(self):
"""widget.html: creating html widgets
TO DO: add tests for all elements by HTML 4 spec.
"""
tests = (
# description, call, expected
('Create text', html.Text('<br> &'), '<br> &'),
('Create raw html', html.Raw('<br> &'), '<br> &'),
('Create br', html.BR(), '<br>'),
('Create hr', html.HR(), '<hr>'),
('Create p', html.P(), '<p></p>'),
)
for description, obj, expected in tests:
result = unicode(obj)
assert result == expected
def testInvalidAttributes(self):
"""widget.html: invalid attributes raises exception
TO DO: add tests for all elements by HTML 4 spec.
"""
py.test.raises(AttributeError, html.BR, name='foo')
def testCompositeElements(self):
"""widget.html: append to and extend composite element"""
html._SORT_ATTRS = 1
element = html.P()
actions = (
# action, data, expected
(element.append,
html.Text('Text & '),
'<p>Text & </p>'),
(element.append,
html.Text('more text. '),
'<p>Text & more text. </p>'),
(element.extend,
(html.Text('And then '), html.Text('some.')),
'<p>Text & more text. And then some.</p>'),
)
for action, data, expected in actions:
action(data)
result = unicode(element)
assert result == expected
coverage_modules = ['MoinMoin.widget.html']
|