summaryrefslogtreecommitdiff
path: root/test-cli/test/runners/simple.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-06 12:46:27 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-06 12:46:27 +0100
commit9f07a57d89a927aa9b172c1bf20c7ab563658c73 (patch)
tree3691cb8d09862db185a628c7bb07df6dd50a64bb /test-cli/test/runners/simple.py
parent98d40cecc9818360984188755e455aa53933aab0 (diff)
downloadboard-9f07a57d89a927aa9b172c1bf20c7ab563658c73.zip
board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.gz
board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.bz2
Fixed multiple errors.
Diffstat (limited to 'test-cli/test/runners/simple.py')
-rw-r--r--test-cli/test/runners/simple.py39
1 files changed, 12 insertions, 27 deletions
diff --git a/test-cli/test/runners/simple.py b/test-cli/test/runners/simple.py
index 084a5b8..dd7c74d 100644
--- a/test-cli/test/runners/simple.py
+++ b/test-cli/test/runners/simple.py
@@ -12,7 +12,6 @@ from test.helpers.globalVariables import globalVar
from test.helpers.testsrv_db import TestSrv_Database
-
class SimpleTestRunner:
""" A Test Runner that shows results in a simple human-readable format.
@@ -33,15 +32,12 @@ class SimpleTestRunner:
self.stream.write(message)
def run(self, test):
- """ Run the given test case or Test Suite.
-
- """
+ """ Run the given test case or Test Suite. """
result = TextTestResult(self, self.__pgObj)
test(result)
- result.testsRun
- # self.writeUpdate("---------------------------------------------\n")
return result
+
class TextTestResult(unittest.TestResult):
# Print in terminal with colors
PASS = '\033[32mPASS\033[0m\n'
@@ -60,14 +56,11 @@ class TextTestResult(unittest.TestResult):
unittest.TestResult.startTest(self, test)
self.runner.writeUpdate("%s : " % test.shortDescription())
# SEND TO DB THE UPDATE THAT WE RUN EACH TEST
- self.__pgObj.update_set_test_row(globalVar.station, globalVar.testid_ctl, globalVar.g_uuid, test.shortDescription(), "RUNNING")
- # psdb = TestSrv_Database()
- # psdb.open("setup.xml")
- # psdb.update_set_test_row(globalVar.station, globalVar.testid_ctl, globalVar.g_uuid, test.shortDescription(), "RUNNING")
+ self.__pgObj.run_test(test.params["testidctl"], test.params["testid"])
def addSuccess(self, test):
unittest.TestResult.addSuccess(self, test)
- self.result=self.PASS
+ self.result = self.PASS
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
@@ -76,25 +69,17 @@ class TextTestResult(unittest.TestResult):
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
- test.longMessage=err[1]
+ test.longMessage = err[1]
self.result = self.FAIL
def stopTest(self, test):
unittest.TestResult.stopTest(self, test)
# display: print test result
self.runner.writeUpdate(self.result)
- # DB: PREPARE THE DATA TO BE INSERTED
- dbdata = {}
- dbdata['uuid'] = globalVar.g_uuid
- dbdata['name'] = test.shortDescription()
- dbdata['result'] = self.result
- dbdata['msg'] = str(test.longMessage)
- #CONVERT FANCY FAIL AND PASS
- if self.result==self.PASS: simple_result="TRUE"
- if self.result == self.FAIL: simple_result = "FALSE"
- elif self.result == self.ERROR: simple_result = "FALSE"
- #SEND TO DB THE RESULT OF THE TEST
- # psdb = TestSrv_Database()
- # psdb.open("setup.xml")
- self.__pgObj.add_test_to_batch(globalVar.g_uuid, test.shortDescription(), globalVar.testid_ctl, simple_result, globalVar.g_mid, test.longMessage)
- # psdb.add_test_to_batch(globalVar.g_uuid, test.shortDescription(), globalVar.testid_ctl, simple_result, globalVar.g_mid, test.longMessage)
+ # SEND TO DB THE RESULT OF THE TEST
+ if self.result == self.PASS:
+ status = "TEST_COMPLETE"
+ else:
+ status = "TEST_FAILED"
+ self.__pgObj.finish_test(test.params["testidctl"], test.params["testid"], status)
+