11 from builtins
import object
13 import xml.etree.cElementTree
as etree
32 self.
_xml_xml.set(
"status",
"0")
33 self.
_xml_xml.set(
"try",
"1")
34 self.
_events_events = etree.SubElement(self.
_xml_xml,
"Events")
39 def info(self, message, timestamp, file=None, line=None):
40 self.
_addMessage_addMessage(message, self.
INFOINFO, timestamp, file, line)
42 def warning(self, message, timestamp, file=None, line=None):
46 self.
_xml_xml.set(
"status",
"1")
48 def error(self, message, timestamp, file=None, line=None):
52 self.
_xml_xml.set(
"status",
"2")
54 def showImage(self, description, filenames, timestamp, file=None, line=None):
55 self.
showFileshowFile(description, filenames, timestamp, file, line, command=
"ImageShow")
57 def showFile(self, description, filenames, timestamp, file=None, line=None, command="FileShow"):
58 if len(filenames) == 0:
59 self.
errorerror(
"No images given!", timestamp)
62 for filename
in filenames:
63 if not os.path.isfile(filename):
64 self.
errorerror(
"File (%s) does not exist" % (filename), timestamp, file, line)
66 hash = Base_getHash(filename)
67 fileList.append(
"%s|%s" % (hash, filename))
70 event = self.
_addMessage_addMessage(description,
"Command", timestamp, file, line)
71 event.attrib[
"command"] = command
73 parameters = etree.SubElement(event,
"Parameters")
74 parameters.text =
",".join(fileList)
77 def _addMessage(self, message, msgType, timestamp, file=None, line=None):
78 assert(isinstance(message, six.string_types))
79 event = etree.SubElement(self.
_events_events,
"Event")
80 event.set(
"type",
unicode(msgType))
81 event.set(
"timestamp",
unicode(timestamp))
82 if file
is not None and line
is not None:
83 event.set(
"file",
unicode(file))
84 event.set(
"line",
unicode(line))
85 etree.SubElement(event,
"Message").text =
unicode(message)
91 def __init__(self, testCaseName, package, author, duration, maintainer=None, file=None, line=None, comment=None, showTestFunctionSortingLiterals=False):
92 assert(isinstance(testCaseName, six.string_types))
97 commonAttributes = {
"name":
unicode(testCaseName),
98 "type":
"FunctionalTestCase"}
100 self.
_xml_xml = etree.Element(
"ExtraTestCaseResult")
102 information = etree.SubElement(self.
_xml_xml,
"Information")
103 testCaseInfo = etree.SubElement(information,
"TestCase")
104 infoAttributes = {
"timeout":
"0"}
105 infoAttributes.update(commonAttributes)
106 for key
in infoAttributes:
107 testCaseInfo.set(key, infoAttributes[key])
108 etree.SubElement(testCaseInfo,
"Author").text =
unicode(author)
109 etree.SubElement(testCaseInfo,
"Package").text =
unicode(package)
110 etree.SubElement(testCaseInfo,
"Maintainer").text =
unicode(maintainer)
if maintainer
else ""
111 etree.SubElement(testCaseInfo,
"Comment").text =
unicode(comment)
if comment
else ""
112 etree.SubElement(testCaseInfo,
"File").text =
unicode(file)
if file
else ""
113 etree.SubElement(testCaseInfo,
"Line").text =
unicode(line)
if line
else ""
114 etree.SubElement(testCaseInfo,
"showTestFunctionSortingLiterals").text =
"1" if showTestFunctionSortingLiterals
else "0"
116 self.
_testFunctions_testFunctions = etree.SubElement(testCaseInfo,
"TestFunctions")
118 result = etree.SubElement(self.
_xml_xml,
"Result")
119 self.
_testCaseResult_testCaseResult = etree.SubElement(result,
"TestCase")
120 resultAttributes = {
"retries":
"0",
122 resultAttributes.update(commonAttributes)
123 for key
in resultAttributes:
129 if number < 10: number =
"00" + str(number)
130 elif number < 100: number =
"0" + str(number)
131 else: number = str(number)
132 name =
"TEST" + number +
"_" + name
133 assert(isinstance(name, six.string_types))
134 info = etree.SubElement(self.
_testFunctions_testFunctions,
"Function")
135 info.set(
"name",
unicode(name))
136 info.set(
"basename",
unicode(basename))
137 info.set(
"is_disabled",
"False")
138 result = etree.SubElement(self.
_testCaseResult_testCaseResult,
"Function")
139 result.set(
"name",
unicode(name))
140 result.set(
"duration",
unicode(duration))
141 result.set(
"is_disabled",
"False")
148 if self.
_status_status < f.status():
149 self.
_status_status = f.status()
154 from .Base
import getHash
as Base_getHash