Author: laukpe
Date: Wed Sep 24 04:08:13 2008
New Revision: 808
Added:
trunk/proto/remote/test/failures.html (contents, props changed)
trunk/proto/remote/test/logging.html (contents, props changed)
Modified:
trunk/proto/remote/python/examplelibrary.py
trunk/proto/remote/python/robotremoteserver.py
Log:
tests/implementation for different failures and logging
Modified: trunk/proto/remote/python/examplelibrary.py
==============================================================================
--- trunk/proto/remote/python/examplelibrary.py (original)
+++ trunk/proto/remote/python/examplelibrary.py Wed Sep 24 04:08:13 2008
@@ -26,6 +26,58 @@
"""This keyword returns a string 'returned string'."""
return 'returned string'
+ # Logging
+
+ def one_message_without_level(self):
+ print 'Hello, world!'
+
+ def multiple_messages_with_different_levels(self):
+ print 'Info message'
+ print '*DEBUG* Debug message'
+ print '*INFO* Second info'
+ print 'this time with two lines'
+ print '*INFO* Third info'
+ print '*TRACE* This is ignored'
+ print '*WARN* Warning'
+
+ def logging_and_failing(self):
+ print '*INFO* This keyword will fail!'
+ print '*WARN* Run for your lives!!'
+ raise AssertionError('Too slow')
+
+ def logging_and_returning(self):
+ print 'Logged message'
+ return 'Returned value'
+
+ # Failures
+
+ def base_exception(self):
+ raise Exception('My message')
+
+ def exception_without_message(self):
+ raise Exception
+
+ def assertion_error(self):
+ raise AssertionError('Failure message')
+
+ def runtime_error(self):
+ raise RuntimeError('Error message')
+
+ def name_error(self):
+ non_existing
+
+ def attribute_error(self):
+ self.non_existing
+
+ def index_error(self):
+ [][0]
+
+ def zero_division(self):
+ 1/0
+
+ def custom_exception(self):
+ raise MyException('My message')
+
# Arguments counts
def no_arguments(self):
@@ -190,7 +242,7 @@
return ( (True, False), [(1, None, MyObject(), {})] )
def return_dictionary(self):
- return {'one': 1, 'true': True}
+ return {'one': 1, 'spam': 'eggs'}
def return_empty_dictionary(self):
return {}
@@ -224,6 +276,9 @@
self.index = index
def __str__(self):
return '<MyObject%s>' % self.index
+
+class MyException(Exception):
+ pass
if __name__ == '__main__':
Modified: trunk/proto/remote/python/robotremoteserver.py
==============================================================================
--- trunk/proto/remote/python/robotremoteserver.py (original)
+++ trunk/proto/remote/python/robotremoteserver.py Wed Sep 24 04:08:13 2008
@@ -44,9 +44,9 @@
self._intercept_stdout()
try:
return_value = self._get_keyword(name)(*args)
- except Exception, exp:
+ except:
result['status'] = 'FAIL'
- result['message'] = str(exp)
+ result['message'] = self._get_error_message()
else:
result['return'] = self._handle_return_value(return_value)
result['output'] = self._restore_stdout()
@@ -73,6 +73,17 @@
if name == 'stop_remote_server':
return self.stop_remote_server
return getattr(self._library, name)
+
+ def _get_error_message(self):
+ # TODO: Return details too
+ exc_type, exc_value, exc_tp = sys.exc_info()
+ name = exc_type.__name__
+ message = str(exc_value)
+ if not message:
+ return name
+ if name in ['AssertionError', 'RuntimeError', 'Exception']:
+ return message
+ return '%s: %s' % (name, message)
def _handle_return_value(self, ret):
if isinstance(ret, (basestring, int, long, float, bool)):
Added: trunk/proto/remote/test/failures.html
==============================================================================
--- (empty file)
+++ trunk/proto/remote/test/failures.html Wed Sep 24 04:08:13 2008
@@ -0,0 +1,247 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+ <style type="text/css">
+html {
+ font-family: Arial,Helvetica,sans-serif;
+ background-color: white;
+ color: black;
+}
+p {
+ max-width: 60em;
+}
+table {
+ border-collapse: collapse;
+ empty-cells: show;
+ margin: 1em 0em;
+ border: 0.1em solid black;
+}
+th, td {
+ border-style: solid;
+ border-width: 0.05em 0.1em;
+ border-color: black;
+ padding: 0.1em 0.2em;
+ height: 1.5em;
+}
+th {
+ background-color: rgb(192, 192, 192);
+ color: black;
+ border-width: 0.1em;
+ font-weight: bold;
+ text-align: center;
+ text-transform: capitalize;
+ letter-spacing: 0.1em;
+}
+/* Widths of named columns */
+col.name {
+ width: 10em;
+}
+.action, .value, .arg {
+ width: 15em;
+}
+/* Properties for the name column
+- td:first-child should work in CSS 2.1 avare browsers (tested in Firefox)
+- col.name is against specs but works in IE
+*/
+td:first-child, col.name {
+ background-color: rgb(240, 240, 240);
+ text-transform: capitalize;
+ letter-spacing: 0.1em;
+}
+/* required for IE */
+th {
+ font-style: normal;
+}
+ </style>
+ <title>Robot Test Cases</title></head>
+<body>
+
+<h1>Robot Test Cases</h1>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="value"
span="4"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Setting</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>value</th>
+
+ <th>Value</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr>
+
+ <td>Library</td>
+
+ <td>Remote</td>
+
+ <td>localhost:${PORT}</td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ <tr><td>Force
Tags</td><td>python</td><td>ruby</td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="value"
span="4"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Variable</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr>
+
+ <td>${PORT} =<br></td><td>8270</td>
+
+
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ <tr>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="action"><col
class="arg" span="3"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Test Case</th>
+
+ <th>Action</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr><td>Base Exception</td><td>[Documentation]</td><td>FAIL</td><td>My
message</td><td></td></tr><tr><td></td><td>Base
Exception</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Exception
Without
Message</td><td>[Documentation]</td><td>FAIL</td><td>Exception</td><td></td></tr><tr><td></td><td>Exception
Without
Message</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Assertion
Error</td><td>[Documentation]</td><td>FAIL</td><td>Failure
message</td><td></td></tr><tr><td></td><td>Assertion
Error</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Runtime
Error</td><td>[Documentation]</td><td>FAIL</td><td>Error
message</td><td></td></tr><tr><td></td><td>Runtime
Error</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr>
+
+ <td>Name Error</td>
+
+ <td>[Documentation]</td>
+
+ <td>FAIL REGEXP:</td>
+
+ <td>(NameError: ).*</td>
+
+ <td></td>
+
+
+
+ </tr>
+
+ <tr>
+
+ <td></td>
+
+ <td>Name Error</td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+
+
+ </tr>
+
<tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Attribute
Error</td><td>[Documentation]</td><td>FAIL REGEXP:</td><td>(AttributeError:
).*</td><td></td></tr><tr><td></td><td>Attribute
Error</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Index
Error</td><td>[Documentation]</td><td>FAIL REGEXP:</td><td>(IndexError:
).*</td><td></td></tr><tr><td></td><td>Index
Error</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr>
+ <tr><td>Zero Division</td><td>[Documentation]</td><td>FAIL
REGEXP:</td><td>(ZeroDivisionError:
).*</td><td></td></tr><tr><td></td><td>Zero
Division</td><td></td><td></td><td></td></tr>
+ <tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Custom
Exception</td><td>[Documentation]</td><td>FAIL
REGEXP:</td><td>(MyException: My
message)</td><td></td></tr><tr><td></td><td>Custom
Exception</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="action"><col
class="arg" span="3"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Keyword</th>
+
+ <th>Action</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+
+
+
<tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+</body></html>
\ No newline at end of file
Added: trunk/proto/remote/test/logging.html
==============================================================================
--- (empty file)
+++ trunk/proto/remote/test/logging.html Wed Sep 24 04:08:13 2008
@@ -0,0 +1,219 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+ <style type="text/css">
+html {
+ font-family: Arial,Helvetica,sans-serif;
+ background-color: white;
+ color: black;
+}
+p {
+ max-width: 60em;
+}
+table {
+ border-collapse: collapse;
+ empty-cells: show;
+ margin: 1em 0em;
+ border: 0.1em solid black;
+}
+th, td {
+ border-style: solid;
+ border-width: 0.05em 0.1em;
+ border-color: black;
+ padding: 0.1em 0.2em;
+ height: 1.5em;
+}
+th {
+ background-color: rgb(192, 192, 192);
+ color: black;
+ border-width: 0.1em;
+ font-weight: bold;
+ text-align: center;
+ text-transform: capitalize;
+ letter-spacing: 0.1em;
+}
+/* Widths of named columns */
+col.name {
+ width: 10em;
+}
+.action, .value, .arg {
+ width: 15em;
+}
+/* Properties for the name column
+- td:first-child should work in CSS 2.1 avare browsers (tested in Firefox)
+- col.name is against specs but works in IE
+*/
+td:first-child, col.name {
+ background-color: rgb(240, 240, 240);
+ text-transform: capitalize;
+ letter-spacing: 0.1em;
+}
+/* required for IE */
+th {
+ font-style: normal;
+}
+ </style>
+ <title>Robot Test Cases</title></head>
+<body>
+
+<h1>Robot Test Cases</h1>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="value"
span="4"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Setting</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>value</th>
+
+ <th>Value</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr>
+
+ <td>Library</td>
+
+ <td>Remote</td>
+
+ <td>localhost:${PORT}</td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ <tr><td>Force
Tags</td><td>python</td><td>ruby</td><td></td><td></td></tr><tr><td>Suite
Setup</td><td>Set Log Level to
DEBUG</td><td></td><td></td><td></td></tr><tr><td>Suite
Teardown</td><td>Reset Log Level</td><td></td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="value"
span="4"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Variable</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ <th>Value</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+ <tr>
+
+ <td>${PORT} =<br></td><td>8270</td>
+
+
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ <tr>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ <td></td>
+
+ </tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="action"><col
class="arg" span="3"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Test Case</th>
+
+ <th>Action</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+
+
+
+ <tr><td>One message Without Level</td><td>[Documentation]</td><td>LOG
1 </td><td>INFO</td><td>Hello, world!</td></tr><tr><td></td><td>One
Message Without
Level</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Log
Levels</td><td>[Documentation]</td><td>LOG
1 </td><td>DEBUG</td><td>Debug
message</td></tr><tr><td></td><td>...</td><td>LOG
2 </td><td>INFO</td><td>Information
message</td></tr><tr><td></td><td>...</td><td>LOG
3 </td><td>WARN</td><td>Warning message</td></tr>
+ <tr><td></td><td>Logging</td><td>Debug
message</td><td>DEBUG</td><td></td></tr><tr><td></td><td>Logging</td><td>Information
message</td><td>INFO</td><td></td></tr><tr><td></td><td>Logging</td><td>Warning
message</td><td>WARN</td><td></td></tr>
+ <tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Multiple
Messages With Different Levels</td><td>[Documentation]</td><td>LOG
1:1 </td><td>INFO</td><td>Info
message</td></tr><tr><td></td><td>...</td><td>LOG
1:2 </td><td>DEBUG</td><td>Debug
message</td></tr><tr><td></td><td>...</td><td>LOG
1:3 </td><td>INFO</td><td>Second info\n<br>this time with two
lines</td></tr><tr><td></td><td>...</td><td>LOG
1:4 </td><td>INFO</td><td>Third
info</td></tr><tr><td></td><td>...</td><td>LOG
1:5 </td><td>WARN</td><td>Warning</td></tr><tr><td></td><td>Multiple
Messages With Different
Levels</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Logging
And Failing</td><td>[Documentation]</td><td>FAIL</td><td>Too
slow</td><td></td></tr><tr><td></td><td>...</td><td>LOG
1:1 </td><td>INFO</td><td>This keyword will
fail!</td></tr><tr><td></td><td>...</td><td>LOG
1:2</td><td>WARN</td><td>Run for your
lives!!</td></tr><tr><td></td><td>...</td><td>LOG
1:3</td><td>FAIL</td><td>Too slow</td></tr><tr><td></td><td>Logging And
Failing</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Logging
And Returning</td><td>[Documentation]</td><td>LOG
1:1</td><td>INFO</td><td>Logged
message</td></tr><tr><td></td><td>...</td><td>LOG
1:2</td><td>INFO</td><td>\${ret} = Returned
value</td></tr><tr><td></td><td>...</td><td>LOG
3:1</td><td>WARN</td><td>This keyword returns
nothing</td></tr><tr><td></td><td>...</td><td>LOG
3:2</td><td>INFO</td><td>\${ret} =${SPACE}</td></tr><tr><td></td><td>${ret}
=</td><td>Logging And
Returning</td><td></td><td></td></tr><tr><td></td><td>Should Be
Equal</td><td>${ret}</td><td>Returned
value</td><td></td></tr><tr><td></td><td>${ret}
=</td><td>Logging</td><td>This keyword returns
nothing</td><td>WARN</td></tr><tr><td></td><td>Should Be
Equal</td><td>${ret}</td><td>${EMPTY}</td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+<table border="1">
+
+ <colgroup span="99"><col class="name"><col class="action"><col
class="arg" span="3"></colgroup>
+ <thead>
+ <tr>
+
+ <th>Keyword</th>
+
+ <th>Action</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ <th>Argument</th>
+
+ </tr>
+
+ </thead>
+ <tbody>
+
+
+
+ <tr><td>Set Log Level To Debug</td><td>${ORIG_LOG_LEVEL} =</td><td>Set
Log Level</td><td>DEBUG</td><td></td></tr><tr><td></td><td>Set Suite
Variable</td><td>$ORIG_LOG_LEVEL</td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Reset
Log Level</td><td>Set Log
Level</td><td>${ORIG_LOG_LEVEL}</td><td></td><td></td></tr>
+
+ </tbody>
+</table>
+
+
+</body></html>
\ No newline at end of file