@@ -14,57 +14,42 @@ from cros.tests.cros_ec_extcon import *
class LavaTestResult(unittest.TestResult):
- def __init__(self, runner):
+ def __init__(self, stream, descriptions, verbosity):
unittest.TestResult.__init__(self)
- self.runner = runner
+ self.stream = stream
def addSuccess(self, test):
unittest.TestResult.addSuccess(self, test)
- self.runner.writeUpdate(
+ self.stream.write(
"<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=pass>\n"
% test.id().rsplit(".")[-1]
)
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
- self.runner.writeUpdate(
+ self.stream.write(
"<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=unknown>\n"
% test.id().rsplit(".")[-1]
)
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
- self.runner.writeUpdate(
+ self.stream.write(
"<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=fail>\n"
% test.id().rsplit(".")[-1]
)
def addSkip(self, test, reason):
unittest.TestResult.addSkip(self, test, reason)
- self.runner.writeUpdate(
+ self.stream.write(
"<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=skip>\n"
% test.id().rsplit(".")[-1]
)
-class LavaTestRunner:
- def __init__(self, stream=sys.stderr, verbosity=0):
- self.stream = stream
- self.verbosity = verbosity
-
- def writeUpdate(self, message):
- self.stream.write(message)
-
- def run(self, test):
- result = LavaTestResult(self)
- test(result)
- result.testsRun
- return result
-
-
if __name__ == "__main__":
unittest.main(
- testRunner=LavaTestRunner(),
+ testRunner=unittest.TextTestRunner(resultclass=LavaTestResult),
# these make sure that some options that are not applicable
# remain hidden from the help menu.
failfast=False,