def parse_results(msg_ops, statistics, fh):
+ exitcode = 0
expected_fail = 0
open_tests = {}
test = open_tests.pop(testname)
except KeyError:
statistics['TESTS_ERROR']+=1
+ exitcode = 1
msg_ops.addError(subunit.RemotedTestCase(testname), subunit.RemoteError(u"Test was never started"))
else:
statistics['TESTS_EXPECTED_OK']+=1
test = open_tests.pop(testname)
except KeyError:
statistics['TESTS_ERROR']+=1
+ exitcode = 1
msg_ops.addError(subunit.RemotedTestCase(testname), subunit.RemoteError(u"Test was never started"))
else:
statistics['TESTS_EXPECTED_FAIL']+=1
test = open_tests.pop(testname)
except KeyError:
statistics['TESTS_ERROR']+=1
+ exitcode = 1
msg_ops.addError(subunit.RemotedTestCase(testname), subunit.RemoteError(u"Test was never started"))
else:
statistics['TESTS_UNEXPECTED_FAIL']+=1
+ exitcode = 1
msg_ops.addFailure(test, remote_error)
elif result == "skip":
statistics['TESTS_SKIP']+=1
msg_ops.addSkip(test, reason)
elif result == "error":
statistics['TESTS_ERROR']+=1
+ exitcode = 1
try:
test = open_tests.pop(testname)
except KeyError:
msg_ops.end_testsuite(testname, "success", reason)
elif result == "testsuite-failure":
msg_ops.end_testsuite(testname, "failure", reason)
+ exitcode = 1
elif result == "testsuite-xfail":
msg_ops.end_testsuite(testname, "xfail", reason)
elif result == "testsuite-error":
msg_ops.end_testsuite(testname, "error", reason)
+ exitcode = 1
else:
raise AssertionError("Recognized but unhandled result %r" %
result)
test = subunit.RemotedTestCase(open_tests.popitem()[1])
msg_ops.addError(test, subunit.RemoteError(u"was started but never finished!"))
statistics['TESTS_ERROR']+=1
+ exitcode = 1
- if statistics['TESTS_ERROR'] > 0:
- return 1
- if statistics['TESTS_UNEXPECTED_FAIL'] > 0:
- return 1
- return 0
+ return exitcode
class SubunitOps(subunit.TestProtocolClient,TestsuiteEnabledTestResult):
self.output+=msg
def startTest(self, test):
+ self.seen_output = True
test = self._add_prefix(test)
if self.strip_ok_output:
self.output = ""
raise ImmediateFail()
def addSkip(self, test, details=None):
+ self.seen_output = True
test = self._add_prefix(test)
self._ops.addSkip(test, details)
self.output = None
self._ops.end_testsuite(name, result, reason)
- def __init__(self, out, prefix, expected_failures, strip_ok_output, fail_immediately=False):
+ def __init__(self, out, prefix=None, expected_failures=None,
+ strip_ok_output=False, fail_immediately=False):
self._ops = out
+ self.seen_output = False
self.output = None
self.prefix = prefix
- self.expected_failures = expected_failures
+ if expected_failures is not None:
+ self.expected_failures = expected_failures
+ else:
+ self.expected_failures = {}
self.strip_ok_output = strip_ok_output
self.xfail_added = 0
self.fail_added = 0
class PlainFormatter(TestsuiteEnabledTestResult):
- def __init__(self, summaryfile, verbose, immediate, statistics,
+ def __init__(self, verbose, immediate, statistics,
totaltests=None):
super(PlainFormatter, self).__init__()
self.verbose = verbose
self.suitesfailed = []
self.suites_ok = 0
self.skips = {}
- self.summaryfile = summaryfile
self.index = 0
self.name = None
self._progress_level = 0
self.totalsuites = totaltests
self.last_time = None
- @classmethod
+ @staticmethod
def _format_time(delta):
minutes, seconds = divmod(delta.seconds, 60)
hours, minutes = divmod(minutes, 60)
self.test_output[self.name] += "UNEXPECTED(%s): %s\n" % (result, testname)
if reason is not None:
- self.test_output[self.name] += "REASON: %s\n" % (reason[1].message.encode("utf-8").strip(),)
+ self.test_output[self.name] += "REASON: %s\n" % (unicode(reason[1]).encode("utf-8").strip(),)
if self.immediate and not self.verbose:
print self.test_output[self.name]
'failure': 'F',
'success': 'S'}.get(result, "?"))
- def summary(self):
- f = open(self.summaryfile, 'w+')
+ def write_summary(self, path):
+ f = open(path, 'w+')
if self.suitesfailed:
f.write("= Failed tests =\n")
f.write("\n")
f.close()
- print "\nA summary with detailed information can be found in:"
- print " %s" % self.summaryfile
-
if (not self.suitesfailed and
not self.statistics['TESTS_UNEXPECTED_FAIL'] and
not self.statistics['TESTS_ERROR']):
self.skips.setdefault(reason, []).append(name)
if self.totalsuites:
self.totalsuites-=1
-
-