mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-06-01 21:01:35 +00:00
Cloud Policy: Remove xunitparser dependency
To avoid an external dependency the required xunit parsing has been implemented directly in the policy.
This commit is contained in:
parent
c6e4e18a23
commit
1c6f56ab79
@ -6,7 +6,7 @@ import shutil
|
|||||||
import smtplib
|
import smtplib
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import xunitparser
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
from britney2 import SuiteClass
|
from britney2 import SuiteClass
|
||||||
from britney2.policies.policy import BasePolicy
|
from britney2.policies.policy import BasePolicy
|
||||||
@ -221,13 +221,38 @@ class CloudPolicy(BasePolicy):
|
|||||||
"""
|
"""
|
||||||
for file_path in results_file_paths:
|
for file_path in results_file_paths:
|
||||||
with open(file_path) as file:
|
with open(file_path) as file:
|
||||||
ts, tr = xunitparser.parse(file)
|
xml = ET.parse(file)
|
||||||
|
root = xml.getroot()
|
||||||
|
|
||||||
for testcase, message in tr.failures:
|
if root.tag == "testsuites":
|
||||||
self.store_test_result(self.failures, cloud, testcase.methodname, message)
|
for testsuite in root:
|
||||||
|
self._parse_xunit_testsuite(cloud, testsuite)
|
||||||
|
else:
|
||||||
|
self._parse_xunit_testsuite(cloud, root)
|
||||||
|
|
||||||
for testcase, message in tr.errors:
|
def _parse_xunit_testsuite(self, cloud, root):
|
||||||
self.store_test_result(self.errors, cloud, testcase.methodname, message)
|
"""Parses the xunit testsuite and stores any failure or error test results.
|
||||||
|
|
||||||
|
:param cloud The name of the cloud, used for storing the results.
|
||||||
|
:param root An XML tree root.
|
||||||
|
"""
|
||||||
|
for el in root:
|
||||||
|
if el.tag == "testcase":
|
||||||
|
for e in el:
|
||||||
|
if e.tag == "failure":
|
||||||
|
type = e.attrib.get('type')
|
||||||
|
message = e.attrib.get('message')
|
||||||
|
info = "{}: {}".format(type, message)
|
||||||
|
self.store_test_result(
|
||||||
|
self.failures, cloud, el.attrib.get('name'), info
|
||||||
|
)
|
||||||
|
if e.tag == "error":
|
||||||
|
type = e.attrib.get('type')
|
||||||
|
message = e.attrib.get('message')
|
||||||
|
info = "{}: {}".format(type, message)
|
||||||
|
self.store_test_result(
|
||||||
|
self.errors, cloud, el.attrib.get('name'), info
|
||||||
|
)
|
||||||
|
|
||||||
def store_test_result(self, results, cloud, test_name, message):
|
def store_test_result(self, results, cloud, test_name, message):
|
||||||
"""Adds the test to the results hash under the given cloud.
|
"""Adds the test to the results hash under the given cloud.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user