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.id = nodeid
|
||||||
self.duration = 0
|
self.duration = 0
|
||||||
self.properties = {}
|
self.properties = {}
|
||||||
|
self.property_insert_order = []
|
||||||
self.testcase = None
|
self.testcase = None
|
||||||
|
|
||||||
def add_property(self, name, value):
|
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):
|
def make_properties_node(self):
|
||||||
|
@ -76,8 +80,8 @@ class _NodeReporter(object):
|
||||||
"""
|
"""
|
||||||
if self.properties:
|
if self.properties:
|
||||||
return Junit.properties([
|
return Junit.properties([
|
||||||
Junit.property(name=name, value=value)
|
Junit.property(name=name, value=self.properties[name])
|
||||||
for name, value in self.properties.items()
|
for name in self.property_insert_order
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@ class DomNode(object):
|
||||||
def __init__(self, dom):
|
def __init__(self, dom):
|
||||||
self.__node = dom
|
self.__node = dom
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.__node.toxml()
|
||||||
|
|
||||||
def find_first_by_tag(self, tag):
|
def find_first_by_tag(self, tag):
|
||||||
return self.find_nth_by_tag(tag, 0)
|
return self.find_nth_by_tag(tag, 0)
|
||||||
|
|
||||||
|
@ -629,8 +632,9 @@ def test_record_property(testdir):
|
||||||
node = dom.find_first_by_tag("testsuite")
|
node = dom.find_first_by_tag("testsuite")
|
||||||
tnode = node.find_first_by_tag("testcase")
|
tnode = node.find_first_by_tag("testcase")
|
||||||
psnode = tnode.find_first_by_tag('properties')
|
psnode = tnode.find_first_by_tag('properties')
|
||||||
pnode = psnode.find_first_by_tag('property')
|
pnodes = psnode.find_by_tag('property')
|
||||||
pnode.assert_attr(name="foo", value="<1")
|
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*')
|
result.stdout.fnmatch_lines('*C3*test_record_property.py*experimental*')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue