changeset 118:77dd69f7c405

* Make the recipe command {{{<python:unittest>}}} transmit the test results to the build master. Closes #32. * Make report data retrieved from the store accessible as {{{xmlio.ParsedElement}}}.
author cmlenz
date Mon, 08 Aug 2005 08:35:07 +0000
parents 2f0f2f006526
children 430c518ebb14
files bitten/build/pythontools.py bitten/store.py bitten/util/xmlio.py
diffstat 3 files changed, 10 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/pythontools.py
+++ b/bitten/build/pythontools.py
@@ -91,17 +91,10 @@
     try:
         fd = open(ctxt.resolve(file), 'r')
         try:
-            from xml.dom import minidom
-            root = minidom.parse(fd).documentElement
-            assert root.tagName == 'unittest-results'
-            for test in root.getElementsByTagName('test'):
-                filename = test.getAttribute('file')
-                if filename.startswith(ctxt.basedir):
-                    filename = filename[len(ctxt.basedir) + 1:]
-                duration = float(test.getAttribute('duration'))
-                name = test.getAttribute('name')
-                status = test.getAttribute('status')
-                # TODO: emit to build master
+            results = xmlio.Fragment()
+            for child in xmlio.parse(fd).children():
+                results.append(child)
+            ctxt.report(results)
         finally:
             fd.close()
     except IOError, e:
--- a/bitten/store.py
+++ b/bitten/store.py
@@ -22,6 +22,7 @@
 import os
 
 from trac.core import *
+from bitten.util import xmlio
 
 log = logging.getLogger('bitten.store')
 
@@ -73,15 +74,15 @@
     ]
 
 
-    class XmlValueWrapper(object):
+    class XmlValueWrapper(xmlio.ParsedElement):
 
         _metadata = None
 
         def __init__(self, value):
             self.value = value
-
-        def __str__(self):
-            return self.value.asString()
+            from xml.dom import minidom
+            dom = minidom.parseString(value.asString())
+            xmlio.ParsedElement.__init__(self, dom.documentElement)
 
         def _get_metadata(self):
             if self._metadata is None:
--- a/bitten/util/xmlio.py
+++ b/bitten/util/xmlio.py
@@ -72,7 +72,7 @@
         stream.
         """
         for child in self.children:
-            if isinstance(child, Element):
+            if isinstance(child, (Element, ParsedElement)):
                 child.write(out, newlines=newlines)
             else:
                 if child[0] == '<':
Copyright (C) 2012-2017 Edgewall Software