1
# -*- coding: iso-8859-1 -*-
3
MoinMoin - MoinMoin.widget.html Tests
5
@copyright: 2003-2004 by J�rgen Hermann <jh@web.de>
6
@license: GNU GPL, see COPYING for details.
10
from MoinMoin.widget import html
11
from MoinMoin import wikiutil
13
class HTMLWidgetsTestCase(unittest.TestCase):
14
"""widget.html: testing html widgets"""
17
"""widget.html: creating html widgets
19
TO DO: add tests for all elements by HTML 4 spec.
22
# description, call, expected
23
('Create text', html.Text('<br> &'), '<br> &'),
24
('Create raw html', html.Raw('<br> &'), '<br> &'),
25
('Create br', html.BR(), '<br>'),
26
('Create hr', html.HR(), '<hr>'),
27
('Create p', html.P(), '<p></p>'),
30
for description, obj, expected in tests:
32
self.assertEqual(result, expected,
33
('%(description)s: expected "%(expected)s" '
34
'but got "%(result)s"') % locals())
36
def testInvalidAttributes(self):
37
"""widegt.html: invalid attributes raises exception
39
TO DO: add tests for all elements by HTML 4 spec.
41
self.assertRaises(AttributeError, html.BR, name='foo')
44
def testCompositeElements(self):
45
"""widget.html: append to and extend composite element"""
50
# action, data, expected
53
'<p>Text & </p>'),
55
html.Text('more text. '),
56
'<p>Text & more text. </p>'),
58
(html.Text('And then '), html.Text('some.')),
59
'<p>Text & more text. And then some.</p>'),
62
for action, data, expected in actions:
64
result = unicode(element)
65
self.assertEqual(result, expected,
66
'Expected "%(expected)s" but got "%(result)s"' % locals())