Revision: ba322e157438
Branch:   default
Author:   Jussi Malinen <jussi.ao.mali...@gmail.com>
Date:     Tue May 27 10:01:34 2014 UTC
Log:      Update issue 811

Added missing librarylisteners.py and also some tests
http://code.google.com/p/robotframework/source/detail?r=ba322e157438

Added:
 /atest/robot/test_libraries/as_listener.txt
 /atest/testdata/test_libraries/as_listener/listenerlibrary.py
 /atest/testdata/test_libraries/as_listener/suite_listenerlibrary.py
 /atest/testdata/test_libraries/as_listener/suite_scope.txt
 /atest/testdata/test_libraries/as_listener/test_scope.txt
 /src/robot/output/librarylisteners.py

=======================================
--- /dev/null
+++ /atest/robot/test_libraries/as_listener.txt Tue May 27 10:01:34 2014 UTC
@@ -0,0 +1,15 @@
+*** Settings ***
+Documentation Tests for libraries using getKeywordNames and runKeyword with **kwargs functionality. In these tests libraries are implemented with Java.
+Suite Setup     Run Tests  ${EMPTY}  test_libraries/as_listener/
+Force Tags      regression  pybot  jybot
+Resource        atest_resource.txt
+
+*** Test Cases ***
+Test scope library gets events
+    Check Test Case  ${TESTNAME}
+New test gets empty events
+    Check Test Case  ${TESTNAME}
+Suite scope library gets events
+    Check Test Case  ${TESTNAME}
+New test gets previous suite scope events
+    Check Test Case  ${TESTNAME}
=======================================
--- /dev/null
+++ /atest/testdata/test_libraries/as_listener/listenerlibrary.py Tue May 27 10:01:34 2014 UTC
@@ -0,0 +1,33 @@
+class listenerlibrary(object):
+
+    ROBOT_LISTENER_API_VERSION = 2
+    ROBOT_LIBRARY_SCOPE = "TEST CASE"
+
+    def __init__(self):
+        self.ROBOT_LIBRARY_LISTENER = self
+        self.events = []
+
+    def get_events(self):
+        return self.events[:]
+
+    def start_test(self, name, attrs):
+        self.events.append('start test %s' % name)
+
+    def end_test(self, name, attrs):
+        self.events.append('end test %s' % name)
+
+    def start_keyword(self, name, attrs):
+        self.events.append('start kw %s' % name)
+
+    def end_keyword(self, name, attrs):
+        self.events.append('end kw %s' % name)
+
+    def events_should_be(self, *expected):
+ assert self._format(self.events) == self._format(expected), 'Expected events\n %s\n actual\n %s' % (self._format(expected), self._format(self.events))
+
+    def events_should_be_empty(self):
+ assert not self.events, 'Expected empty events, has %s' % self._format(self.events)
+
+    def _format(self, events):
+        return ' | '.join(events)
+
=======================================
--- /dev/null
+++ /atest/testdata/test_libraries/as_listener/suite_listenerlibrary.py Tue May 27 10:01:34 2014 UTC
@@ -0,0 +1,5 @@
+from listenerlibrary import listenerlibrary
+
+class suite_listenerlibrary(listenerlibrary):
+
+    ROBOT_LIBRARY_SCOPE = "TEST SUITE"
=======================================
--- /dev/null
+++ /atest/testdata/test_libraries/as_listener/suite_scope.txt Tue May 27 10:01:34 2014 UTC
@@ -0,0 +1,17 @@
+*** Settings ***
+Library    suite_listenerlibrary.py
+
+*** 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
+        ...             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
+            ...         start kw suite_listenerlibrary.Events Should Be
+            ...         end kw suite_listenerlibrary.Events Should Be
+            ...         end test Suite scope library gets events
+ ... start test New test gets previous suite scope events
+            ...         start kw suite_listenerlibrary.Events Should Be
=======================================
--- /dev/null
+++ /atest/testdata/test_libraries/as_listener/test_scope.txt Tue May 27 10:01:34 2014 UTC
@@ -0,0 +1,12 @@
+*** Settings ***
+Library    listenerlibrary.py
+
+*** 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
+        ...             start kw listenerlibrary.Events Should Be
+
+New test gets empty events
+    Events should be empty
=======================================
--- /dev/null
+++ /src/robot/output/librarylisteners.py       Tue May 27 10:01:34 2014 UTC
@@ -0,0 +1,33 @@
+#  Copyright 2008-2014 Nokia Solutions and Networks
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+from .listeners import Listeners, _ListenerProxy
+
+
+class LibraryListeners(Listeners):
+
+    def __init__(self):
+        self._running_test = False
+        self._setup_or_teardown_type = None
+
+    def __nonzero__(self):
+        return True
+
+    @property
+    def _listeners(self):
+        from robot.running import EXECUTION_CONTEXTS
+        if not EXECUTION_CONTEXTS.current:
+            return []
+        return [_ListenerProxy(listener=listener) for listener in
+                EXECUTION_CONTEXTS.current.namespace.library_listeners]

--

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