1
# -*- coding: iso-8859-1 -*-
3
MoinMoin - MoinMoin.wikixml.marshal Tests
5
@copyright: 2002-2004 by J�rgen Hermann <jh@web.de>
6
@license: GNU GPL, see COPYING for details.
11
from MoinMoin.wikixml import marshal
13
class MarshalTestCase(unittest.TestCase):
14
"""Testing Marshal used for ...XXX"""
17
cvar = 'Class Variable'
18
def __init__(self, value):
22
# value, xml representation in a marshal object
23
(None, '<data><prop><none/></prop></data>'),
24
("string", '<data><prop>string</prop></data>'),
25
([1, "abc"], '<data><prop><item>1</item><item>abc</item></prop></data>'),
26
((1, "abc"), '<data><prop><item>1</item><item>abc</item></prop></data>'),
27
({"abc": 1}, '<data><prop><abc>1</abc></prop></data>'),
28
(1, '<data><prop>1</prop></data>'),
29
(Data('value'), '<data><prop><data><ivar>value</ivar></data></prop></data>'),
30
(array.array("i", [42]), "<data><prop>array('i', [42])</prop></data>"),
31
(buffer("0123456789", 2, 3),"<data><prop>234</prop></data>"),
35
self.obj = marshal.Marshal()
37
def testCreateMarshal(self):
38
"""wikixml.marshal: create new marshal"""
39
self._checkData(self.obj, '<data></data>')
41
def testSetMarshalProperty(self):
42
"""wikixml.marshal: setting marshal property"""
43
for value, xml in self.prop:
45
self._checkData(self.obj, xml)
47
def _canonize(self, xml):
48
xml = xml.replace('\n', '')
51
def _checkData(self, obj, xml):
52
objXML = self._canonize(obj.toXML())
53
expected = self._canonize(xml)
54
self.assertEqual(objXML, expected,
55
'Expected "%(expected)s" but got "%(objXML)s"' % locals())