junitxml: keep track of custom property insert order
+ review: should we allow the same key multile times
This commit is contained in:
parent
faed54d6c7
commit
9b04958303
|
@ -64,10 +64,14 @@ class _NodeReporter(object):
|
|||
self.id = nodeid
|
||||
self.duration = 0
|
||||
self.properties = {}
|
||||
self.property_insert_order = []
|
||||
self.testcase = None
|
||||
|
||||
def add_property(self, name, value):
|
||||
self.properties[str(name)] = bin_xml_escape(value)
|
||||
name = str(name)
|
||||
if name not in self.property_insert_order:
|
||||
self.property_insert_order.append(name)
|
||||
self.properties[name] = bin_xml_escape(value)
|
||||
|
||||
|
||||
def make_properties_node(self):
|
||||
|
@ -76,8 +80,8 @@ class _NodeReporter(object):
|
|||
"""
|
||||
if self.properties:
|
||||
return Junit.properties([
|
||||
Junit.property(name=name, value=value)
|
||||
for name, value in self.properties.items()
|
||||
Junit.property(name=name, value=self.properties[name])
|
||||
for name in self.property_insert_order
|
||||
])
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ class DomNode(object):
|
|||
def __init__(self, dom):
|
||||
self.__node = dom
|
||||
|
||||
def __repr__(self):
|
||||
return self.__node.toxml()
|
||||
|
||||
def find_first_by_tag(self, tag):
|
||||
return self.find_nth_by_tag(tag, 0)
|
||||
|
||||
|
@ -629,8 +632,9 @@ def test_record_property(testdir):
|
|||
node = dom.find_first_by_tag("testsuite")
|
||||
tnode = node.find_first_by_tag("testcase")
|
||||
psnode = tnode.find_first_by_tag('properties')
|
||||
pnode = psnode.find_first_by_tag('property')
|
||||
pnode.assert_attr(name="foo", value="<1")
|
||||
pnodes = psnode.find_by_tag('property')
|
||||
pnodes[0].assert_attr(name="bar", value="1")
|
||||
pnodes[1].assert_attr(name="foo", value="<1")
|
||||
result.stdout.fnmatch_lines('*C3*test_record_property.py*experimental*')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue