2 new revisions:

Revision: dcbc2df1b16c
Branch:   default
Author:   Jussi Malinen <jussi.ao.mali...@gmail.com>
Date:     Wed May 28 10:09:35 2014 UTC
Log:      Update issue 811...
http://code.google.com/p/robotframework/source/detail?r=dcbc2df1b16c

Revision: 16de506711fa
Branch:   default
Author:   Jussi Malinen <jussi.ao.mali...@gmail.com>
Date:     Wed May 28 10:09:48 2014 UTC
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=16de506711fa

==============================================================================
Revision: dcbc2df1b16c
Branch:   default
Author:   Jussi Malinen <jussi.ao.mali...@gmail.com>
Date:     Wed May 28 10:09:35 2014 UTC
Log:      Update issue 811

If a library works as a listener, it is created at the beginning of the scope. (Test scope listener will get start test event, suite scope will get the start suite etc)
http://code.google.com/p/robotframework/source/detail?r=dcbc2df1b16c

Modified:
 /atest/testdata/test_libraries/as_listener/listenerlibrary.py
 /atest/testdata/test_libraries/as_listener/suite_scope.txt
 /atest/testdata/test_libraries/as_listener/test_scope.txt
 /src/robot/running/testlibraries.py

=======================================
--- /atest/testdata/test_libraries/as_listener/listenerlibrary.py Tue May 27 14:43:45 2014 UTC +++ /atest/testdata/test_libraries/as_listener/listenerlibrary.py Wed May 28 10:09:35 2014 UTC
@@ -10,6 +10,9 @@
     def get_events(self):
         return self.events[:]

+    def _start_suite(self, name, attrs):
+        self.events.append('start suite %s' % name)
+
     def _start_test(self, name, attrs):
         self.events.append('start test %s' % name)

=======================================
--- /atest/testdata/test_libraries/as_listener/suite_scope.txt Tue May 27 10:01:34 2014 UTC +++ /atest/testdata/test_libraries/as_listener/suite_scope.txt Wed May 28 10:09:35 2014 UTC
@@ -3,13 +3,13 @@

 *** Test Cases ***
 Suite scope library gets events
-    Log     not listened yet
-    Events should be empty
-    Events should be    end kw suite_listenerlibrary.Events Should Be Empty
+    Events should be    start suite Suite Scope
+        ...             start test Suite scope library gets events
         ...             start kw suite_listenerlibrary.Events Should Be

 New test gets previous suite scope events
-    Events should be    end kw suite_listenerlibrary.Events Should Be Empty
+    Events should be    start suite Suite Scope
+            ...         start test Suite scope library gets events
             ...         start kw suite_listenerlibrary.Events Should Be
             ...         end kw suite_listenerlibrary.Events Should Be
             ...         end test Suite scope library gets events
=======================================
--- /atest/testdata/test_libraries/as_listener/test_scope.txt Tue May 27 10:01:34 2014 UTC +++ /atest/testdata/test_libraries/as_listener/test_scope.txt Wed May 28 10:09:35 2014 UTC
@@ -3,10 +3,9 @@

 *** Test Cases ***
 Test scope library gets events
-    Log     not listened yet
-    Events should be empty
-    Events should be    end kw listenerlibrary.Events Should Be Empty
+    Events should be    start test Test scope library gets events
         ...             start kw listenerlibrary.Events Should Be

 New test gets empty events
-    Events should be empty
+    Events should be    start test New test gets empty events
+        ...             start kw listenerlibrary.Events Should Be
=======================================
--- /src/robot/running/testlibraries.py Mon May 26 15:18:30 2014 UTC
+++ /src/robot/running/testlibraries.py Wed May 28 10:09:35 2014 UTC
@@ -71,6 +71,7 @@
         self.positional_args = []
         self.named_args = {}
         self._instance_cache = []
+        self._has_listener = False # Set when instance is created
         self._libinst = None
         if libcode is not None:
             self._doc = getdoc(libcode)
@@ -87,9 +88,14 @@

     @property
     def listener(self):
-        if not self._libinst:
+        if self._has_listener:
+            return self._get_instance_listener(self.get_instance())
+        return None
+
+    def _get_instance_listener(self, inst):
+        if not inst:
             return None
-        return getattr(self._libinst, 'ROBOT_LIBRARY_LISTENER', None)
+        return getattr(inst, 'ROBOT_LIBRARY_LISTENER', None)

     def create_handlers(self):
         if self._libcode:
@@ -161,7 +167,9 @@
     def _get_instance(self):
         with OutputCapturer(library_import=True):
             try:
- return self._libcode(*self.positional_args, **self.named_args) + instance = self._libcode(*self.positional_args, **self.named_args) + self._has_listener = self._get_instance_listener(instance) is not None
+                return instance
             except:
                 self._raise_creating_instance_failed()


==============================================================================
Revision: 16de506711fa
Branch:   default
Author:   Jussi Malinen <jussi.ao.mali...@gmail.com>
Date:     Wed May 28 10:09:48 2014 UTC
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=16de506711fa


--

--- 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