Revision: a67147545207
Branch:   default
Author:   Jussi Malinen <jussi.ao.mali...@gmail.com>
Date:     Mon May 26 15:18:30 2014 UTC
Log:      First implementation for libraries acting as listeners.

Update issue 811
Status: Started
Owner: jussi.ao.mali...@gmail.com
Cc: pekka.kla...@gmail.com

First implementation still lacking tests and support for methods starting with underscore.
http://code.google.com/p/robotframework/source/detail?r=a67147545207

Modified:
 /src/robot/output/listeners.py
 /src/robot/output/output.py
 /src/robot/running/namespace.py
 /src/robot/running/testlibraries.py

=======================================
--- /src/robot/output/listeners.py      Thu Jan 23 14:00:53 2014 UTC
+++ /src/robot/output/listeners.py      Mon May 26 15:18:30 2014 UTC
@@ -218,10 +218,10 @@
                 'output_file', 'report_file', 'log_file', 'debug_file',
                 'xunit_file', 'close']

-    def __init__(self, name, args):
-        listener = self._import_listener(name, args)
+    def __init__(self, name=None, args=None, listener=None):
+        listener = listener or self._import_listener(name, args)
         AbstractLoggerProxy.__init__(self, listener)
-        self.name = name
+        self.name = name or type(listener).__name__
         self.version = self._get_version(listener)
         self.is_java = utils.is_jython and isinstance(listener, Object)

=======================================
--- /src/robot/output/output.py Thu Jan 23 14:00:53 2014 UTC
+++ /src/robot/output/output.py Mon May 26 15:18:30 2014 UTC
@@ -14,6 +14,7 @@

 from . import pyloggingconf
 from .debugfile import DebugFile
+from .librarylisteners import LibraryListeners
 from .listeners import Listeners
 from .logger import LOGGER
 from .loggerhelper import AbstractLogger
@@ -30,8 +31,10 @@

     def _register_loggers(self, listeners, debugfile):
         LOGGER.register_context_changing_logger(self._xmllogger)
-        for logger in Listeners(listeners), DebugFile(debugfile):
-            if logger: LOGGER.register_logger(logger)
+        for logger in (Listeners(listeners), LibraryListeners(),
+                       DebugFile(debugfile)):
+            if logger:
+                LOGGER.register_logger(logger)
         LOGGER.disable_message_cache()

     def close(self, result):
=======================================
--- /src/robot/running/namespace.py     Fri Apr 25 13:22:40 2014 UTC
+++ /src/robot/running/namespace.py     Mon May 26 15:18:30 2014 UTC
@@ -55,6 +55,12 @@
         self._imported_resource_files = ImportCache()
         self._imported_variable_files = ImportCache()

+    @property
+    def library_listeners(self):
+        for lib in self._testlibs.itervalues():
+            if lib.listener:
+                yield lib.listener
+
     def handle_imports(self):
         self._import_default_libraries()
         self._handle_imports(self._imports)
=======================================
--- /src/robot/running/testlibraries.py Thu Jan 23 14:00:53 2014 UTC
+++ /src/robot/running/testlibraries.py Mon May 26 15:18:30 2014 UTC
@@ -85,6 +85,12 @@
     def doc(self):
         return self._doc

+    @property
+    def listener(self):
+        if not self._libinst:
+            return None
+        return getattr(self._libinst, 'ROBOT_LIBRARY_LISTENER', None)
+
     def create_handlers(self):
         if self._libcode:
             self._libinst = self.get_instance()

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to