[apycotlib] add a 'displayname' argument to the atest.Test.run_checker method (closes #3241610)
authorDavid Douard <david.douard@logilab.fr>
Mon, 14 Oct 2013 16:53:54 +0200
changeset 1455 4adba1b659f9
parent 1454 a3dcc0a1d6fa
child 1456 c7e5156479d1
[apycotlib] add a 'displayname' argument to the atest.Test.run_checker method (closes #3241610) so one can run the same checker several times in one test session, like:: with na.apycot_environment(plan) as test: na.install_environment(test) checker, status = test.run_checker('pyunit', displayname='Unit tests') checker, status = test.run_checker('pyunit', displayname='Regressions', test_dirs=['reg'])
_apycotlib/atest.py
_apycotlib/writer.py
--- a/_apycotlib/atest.py	Mon Oct 14 16:49:34 2013 +0200
+++ b/_apycotlib/atest.py	Mon Oct 14 16:53:54 2013 +0200
@@ -264,7 +264,7 @@
                               path=path, tb=True)
             self._failed_pp.add(pptype)
 
-    def run_checker(self, id, nonexecuted=False, **kwargs):
+    def run_checker(self, id, displayname=None, nonexecuted=False, **kwargs):
         """run all checks in the test environment"""
         options = options_dict(self.texec['options'])
         options.update(kwargs)
@@ -275,7 +275,7 @@
             check_writer.end(SKIPPED)
             return None, SKIPPED # XXX
         checker = get_registered('checker', id)(check_writer, options)
-        check_writer.start(checker)
+        check_writer.start(checker, name=displayname)
         if checker.need_preprocessor in self._failed_pp:
             msg = 'Can\'t run checker %s: preprocessor %s have failed'
             check_writer.fatal(msg, checker.id, checker.need_preprocessor)
--- a/_apycotlib/writer.py	Mon Oct 14 16:49:34 2013 +0200
+++ b/_apycotlib/writer.py	Mon Oct 14 16:53:54 2013 +0200
@@ -161,9 +161,12 @@
 class CheckDataWriter(BaseDataWriter):
     """Writer intended to report Check level log and result."""
 
-    def start(self, checker):
+    def start(self, checker, name=None):
         """Register the given checker as started"""
-        crname = getattr(checker, 'id', checker) # may be the checked id
+        if name is not None:
+            crname = name
+        else:
+            crname = getattr(checker, 'id', checker) # may be the checked id
         data = self._cnxh.http_post(self._url, vid='create_subentity',
                                     __cwetype__='CheckResult',
                                     __cwrel__='during_execution',