From c1fe7b498a680a4f9d94e3633e6d9c566fb61fe4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Sep 2010 21:55:22 +0200 Subject: subunit: Use standard addError method implementation. --- selftest/subunithelper.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'selftest/subunithelper.py') diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 3328741246..31550542f2 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -79,8 +79,7 @@ def parse_results(msg_ops, statistics, fh): if not terminated: statistics['TESTS_ERROR']+=1 - msg_ops.end_test(testname, "error", True, - "reason (%s) interrupted" % result) + msg_ops.addError(subunit.RemotedTestCase(testname), "reason (%s) interrupted" % result) return 1 else: reason = None @@ -89,8 +88,7 @@ def parse_results(msg_ops, statistics, fh): open_tests.remove(testname) except ValueError: statistics['TESTS_ERROR']+=1 - msg_ops.end_test(testname, "error", True, - "Test was never started") + msg_ops.addError(subunit.RemotedTestCase(testname), "Test was never started") else: statistics['TESTS_EXPECTED_OK']+=1 msg_ops.end_test(testname, "success", False, reason) @@ -99,8 +97,7 @@ def parse_results(msg_ops, statistics, fh): open_tests.remove(testname) except ValueError: statistics['TESTS_ERROR']+=1 - msg_ops.end_test(testname, "error", True, - "Test was never started") + msg_ops.addError(subunit.RemotedTestCase(testname), "Test was never started") else: statistics['TESTS_EXPECTED_FAIL']+=1 msg_ops.end_test(testname, "xfail", False, reason) @@ -110,8 +107,7 @@ def parse_results(msg_ops, statistics, fh): open_tests.remove(testname) except ValueError: statistics['TESTS_ERROR']+=1 - msg_ops.end_test(testname, "error", True, - "Test was never started") + msg_ops.addError(subunit.RemotedTestCase(testname), "Test was never started") else: statistics['TESTS_UNEXPECTED_FAIL']+=1 msg_ops.end_test(testname, "failure", True, reason) @@ -128,7 +124,7 @@ def parse_results(msg_ops, statistics, fh): open_tests.remove(testname) except ValueError: pass - msg_ops.end_test(testname, "error", True, reason) + msg_ops.addError(subunit.RemotedTestCase(testname), reason) elif result == "skip-testsuite": msg_ops.skip_testsuite(testname) elif result == "testsuite-success": @@ -171,6 +167,9 @@ def parse_results(msg_ops, statistics, fh): class SubunitOps(subunit.TestProtocolClient,TestsuiteEnabledTestResult): + def addError(self, test, details=None): + self.end_test(test.id(), "error", details) + def end_test(self, name, result, reason=None): if reason: self._stream.write("%s: %s [\n%s\n]\n" % (result, name, reason)) @@ -259,6 +258,9 @@ class FilterOps(testtools.testresult.TestResult): self._ops.startTest(test) + def addError(self, test, details=None): + self.end_test(test.id(), "error", details) + def end_test(self, testname, result, unexpected, reason): if self.prefix is not None: testname = self.prefix + testname -- cgit