summaryrefslogtreecommitdiff
path: root/test/gtest_xml_test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/gtest_xml_test_utils.py')
-rwxr-xr-xtest/gtest_xml_test_utils.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/test/gtest_xml_test_utils.py b/test/gtest_xml_test_utils.py
index 341956b..1e03585 100755
--- a/test/gtest_xml_test_utils.py
+++ b/test/gtest_xml_test_utils.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-#
# Copyright 2006, Google Inc.
# All rights reserved.
#
@@ -31,15 +29,10 @@
"""Unit test utilities for gtest_xml_output"""
-__author__ = 'eefacm@gmail.com (Sean Mcafee)'
-
import re
from xml.dom import minidom, Node
-
import gtest_test_utils
-
-GTEST_OUTPUT_FLAG = '--gtest_output'
GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'
class GTestXMLTestCase(gtest_test_utils.TestCase):
@@ -101,26 +94,29 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self.assertEquals(
len(expected_children), len(actual_children),
'number of child elements differ in element ' + actual_node.tagName)
- for child_id, child in expected_children.items():
+ for child_id, child in expected_children.iteritems():
self.assert_(child_id in actual_children,
'<%s> is not in <%s> (in element %s)' %
(child_id, actual_children, actual_node.tagName))
self.AssertEquivalentNodes(child, actual_children[child_id])
identifying_attribute = {
- 'testsuites': 'name',
- 'testsuite': 'name',
- 'testcase': 'name',
- 'failure': 'message',
- }
+ 'testsuites': 'name',
+ 'testsuite': 'name',
+ 'testcase': 'name',
+ 'failure': 'message',
+ 'property': 'name',
+ }
def _GetChildren(self, element):
"""
Fetches all of the child nodes of element, a DOM Element object.
Returns them as the values of a dictionary keyed by the IDs of the
- children. For <testsuites>, <testsuite> and <testcase> elements, the ID
- is the value of their "name" attribute; for <failure> elements, it is
- the value of the "message" attribute; CDATA sections and non-whitespace
+ children. For <testsuites>, <testsuite>, <testcase>, and <property>
+ elements, the ID is the value of their "name" attribute; for <failure>
+ elements, it is the value of the "message" attribute; for <properties>
+ elements, it is the value of their parent's "name" attribute plus the
+ literal string "properties"; CDATA sections and non-whitespace
text nodes are concatenated into a single CDATA section with ID
"detail". An exception is raised if any element other than the above
four is encountered, if two child elements with the same identifying
@@ -130,11 +126,17 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
children = {}
for child in element.childNodes:
if child.nodeType == Node.ELEMENT_NODE:
- self.assert_(child.tagName in self.identifying_attribute,
- 'Encountered unknown element <%s>' % child.tagName)
- childID = child.getAttribute(self.identifying_attribute[child.tagName])
- self.assert_(childID not in children)
- children[childID] = child
+ if child.tagName == 'properties':
+ self.assert_(child.parentNode is not None,
+ 'Encountered <properties> element without a parent')
+ child_id = child.parentNode.getAttribute('name') + '-properties'
+ else:
+ self.assert_(child.tagName in self.identifying_attribute,
+ 'Encountered unknown element <%s>' % child.tagName)
+ child_id = child.getAttribute(
+ self.identifying_attribute[child.tagName])
+ self.assert_(child_id not in children)
+ children[child_id] = child
elif child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]:
if 'detail' not in children:
if (child.nodeType == Node.CDATA_SECTION_NODE or
@@ -187,8 +189,8 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
# Replaces the source line information with a normalized form.
cdata = re.sub(source_line_pat, '\\1*\n', child.nodeValue)
# Removes the actual stack trace.
- child.nodeValue = re.sub(r'\nStack trace:\n(.|\n)*',
- '', cdata)
+ child.nodeValue = re.sub(r'Stack trace:\n(.|\n)*',
+ 'Stack trace:\n*', cdata)
for child in element.childNodes:
if child.nodeType == Node.ELEMENT_NODE:
self.NormalizeXml(child)