TupleField not friendly whith pretty xml..
Mohamed Barwani
mohamedb at sgi.com
Fri Aug 29 05:46:18 UTC 2008
If my xml files are indented and clean, and they happen to have a TupleField in
the extension arguments, then qmtest fail to load the xml file..
ERROR:
xml_database.TestFileError: A problem occurred while loading the
XML test file "mysuite.touch1":Text instance has no attribute
'tagName'
The following patch fixes the issue.
qm/fields.py | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/qm/fields.py b/qm/fields.py
index 7d9a1ed..1aaa23a 100644
--- a/qm/fields.py
+++ b/qm/fields.py
@@ -812,8 +812,19 @@ class TupleField(Field):
def GetValueFromDomNode(self, node, attachment_store):
- values = []
- for f, element in map(None, self.__fields, node.childNodes):
+ # Make sure 'node' is a '<tuple>' element.
+ if node.nodeType != xml.dom.Node.ELEMENT_NODE \
+ or node.tagName != "tuple":
+ raise qm.QMException, \
+ qm.error("dom wrong tag for field",
+ name=self.GetName(),
+ right_tag="tuple",
+ wrong_tag=node.tagName)
+ values = []
+ # filter Text Node
+ children = [ n for n in node.childNodes
+ if n.nodeType == xml.dom.Node.ELEMENT_NODE ]
+ for f, element in map(None, self.__fields, children):
values.append(f.GetValueFromDomNode(element, attachment_store))
return self.Validate(values)
cheers
--
Mohamed Barwani
ASGQA
"what can be said at all can be said clearly, and what we cannot talk about we must pass over in silence."
-- Ludwig Wittgenstein
More information about the qmtest
mailing list