Commit 4323acc0 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Allow give a title to the test runner.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2328 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent a0ed4650
...@@ -111,8 +111,9 @@ if CONSOLE_LOG: ...@@ -111,8 +111,9 @@ if CONSOLE_LOG:
class NeoTestRunner(unittest.TestResult): class NeoTestRunner(unittest.TestResult):
""" Custom result class to build report with statistics per module """ """ Custom result class to build report with statistics per module """
def __init__(self): def __init__(self, title):
unittest.TestResult.__init__(self) unittest.TestResult.__init__(self)
self._title = title
self.modulesStats = {} self.modulesStats = {}
self.failedImports = {} self.failedImports = {}
self.lastStart = None self.lastStart = None
...@@ -196,6 +197,7 @@ class NeoTestRunner(unittest.TestResult): ...@@ -196,6 +197,7 @@ class NeoTestRunner(unittest.TestResult):
import datetime import datetime
success = self.testsRun - len(self.errors) - len(self.failures) success = self.testsRun - len(self.errors) - len(self.failures)
s = """ s = """
Title : %s
Date : %s Date : %s
Node : %s Node : %s
Machine : %s Machine : %s
...@@ -204,6 +206,7 @@ class NeoTestRunner(unittest.TestResult): ...@@ -204,6 +206,7 @@ class NeoTestRunner(unittest.TestResult):
Directory : %s Directory : %s
Status : %7.3f%% Status : %7.3f%%
""" % ( """ % (
self._title,
datetime.date.today().isoformat(), datetime.date.today().isoformat(),
platform.node(), platform.node(),
platform.machine(), platform.machine(),
...@@ -284,8 +287,8 @@ class NeoTestRunner(unittest.TestResult): ...@@ -284,8 +287,8 @@ class NeoTestRunner(unittest.TestResult):
def build(self): def build(self):
self.time = sum([s.time for s in self.modulesStats.values()]) self.time = sum([s.time for s in self.modulesStats.values()])
args = (self.testsRun, len(self.errors), len(self.failures)) self.subject = "%s: %s Tests, %s Errors, %s Failures" % (self._title,
self.subject = "Neo : %s Tests, %s Errors, %s Failures" % args self.testsRun, len(self.errors), len(self.failures))
self._summary = self._buildSummary() self._summary = self._buildSummary()
self._errors = self._buildErrors() self._errors = self._buildErrors()
self._warnings = self._buildWarnings() self._warnings = self._buildWarnings()
...@@ -341,6 +344,7 @@ if __name__ == "__main__": ...@@ -341,6 +344,7 @@ if __name__ == "__main__":
parser.add_option('', '--recipient', action='append') parser.add_option('', '--recipient', action='append')
parser.add_option('', '--sender') parser.add_option('', '--sender')
parser.add_option('', '--server') parser.add_option('', '--server')
parser.add_option('', '--title')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
# check arguments # check arguments
...@@ -352,7 +356,7 @@ if __name__ == "__main__": ...@@ -352,7 +356,7 @@ if __name__ == "__main__":
mail_server = mail_server.split(':') mail_server = mail_server.split(':')
# run requested tests # run requested tests
runner = NeoTestRunner() runner = NeoTestRunner(title=options.title or 'Neo')
try: try:
if options.unit: if options.unit:
runner.run('Unit tests', UNIT_TEST_MODULES) runner.run('Unit tests', UNIT_TEST_MODULES)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment