Author: pekka.klarck
Date: Sun Apr 12 14:40:08 2009
New Revision: 1784

Modified:
   trunk/src/robot/libraries/BuiltIn.py
   trunk/src/robot/libraries/Collections.py
   trunk/src/robot/libraries/Dialogs.py
   trunk/src/robot/libraries/Screenshot.py
   trunk/src/robot/libraries/String.py
   trunk/src/robot/libraries/Telnet.py

Log:
Updated general docs (issue 283) plus some cleanup for String and Dialog

Modified: trunk/src/robot/libraries/BuiltIn.py
==============================================================================
--- trunk/src/robot/libraries/BuiltIn.py        (original)
+++ trunk/src/robot/libraries/BuiltIn.py        Sun Apr 12 14:40:08 2009
@@ -1411,7 +1411,7 @@

     `BuiltIn` is Robot Framework's standard library that provides a set
     of generic keywords needed often. It is imported automatically and
-    thus always available.  The provided keywords can be used, for example,
+    thus always available. The provided keywords can be used, for example,
     for verifications (e.g. `Should Be Equal`, `Should Contain`),
     conversions (e.g. `Convert To Integer`) and for various other purposes
     (e.g. `Log`, `Sleep`, `Run Keyword If`, `Set Global Variable`).

Modified: trunk/src/robot/libraries/Collections.py
==============================================================================
--- trunk/src/robot/libraries/Collections.py    (original)
+++ trunk/src/robot/libraries/Collections.py    Sun Apr 12 14:40:08 2009
@@ -617,7 +617,7 @@

"""A test library providing keywords for handling lists and dictionaries.

-    Collections is Robot Framework's standard library that provides a
+    `Collections` is Robot Framework's standard library that provides a
     set of keywords for handling Python lists and dictionaries. This
     library has keywords, for example, for modifying and getting
     values from lists and dictionaries (e.g. `Append To List`, `Get

Modified: trunk/src/robot/libraries/Dialogs.py
==============================================================================
--- trunk/src/robot/libraries/Dialogs.py        (original)
+++ trunk/src/robot/libraries/Dialogs.py        Sun Apr 12 14:40:08 2009
@@ -15,19 +15,20 @@

 """A test library providing dialogs for interacting with users.

-Dialogs is a test library that provides means for pausing the test
-execution and getting input from users. The dialogs are slightly
-different depending on are tests run on Python or Jython but they
-provide the same functionality.
+`Dialogs` is Robot Framework's standard library that provides means
+for pausing the test execution and getting input from users. The
+dialogs are slightly different depending on are tests run on Python or
+Jython but they provide the same functionality.
 """

 import sys
+
 try:
-    import robot
-    ROBOT_LIBRARY_VERSION = robot.utils.get_version()
-    del robot
+    from robot import utils
 except ImportError:
-    pass
+    __version__ = 'unknown'
+else:
+    __version__ = utils.get_version()


 DIALOG_TITLE = 'Robot Framework'
@@ -45,7 +46,9 @@
     opened for defining the error message. `default_error` is the
     possible default value shown in the error message dialog.
     """
-    _execute_manual_step(message, default_error)
+    if not _execute_manual_step(message, default_error):
+        msg = get_value_from_user('Give error message:', default_error)
+        raise AssertionError(msg)

 def get_value_from_user(message, default_value=''):
     """Pauses the test execution and asks user to input a value.
@@ -53,12 +56,15 @@
`message` is the instruction shown in the dialog. `default_value` is the
     possible default value shown in the input field.
     """
-    return _get_value_from_user(message, default_value)
+    value = _get_value_from_user(message, default_value)
+    if value is None:
+        raise ValueError('No value provided by user')
+    return value


 if sys.platform.startswith('java'):

- from javax.swing.JOptionPane import showMessageDialog, showOptionDialog,\ + from javax.swing.JOptionPane import showMessageDialog, showOptionDialog, \
         showInputDialog, YES_NO_OPTION, PLAIN_MESSAGE


@@ -68,17 +74,11 @@
     def _execute_manual_step(message, default_error):
status = showOptionDialog(None, message, DIALOG_TITLE, YES_NO_OPTION, PLAIN_MESSAGE, None, ['PASS', 'FAIL'], None)
-        if status != 0:
- msg = _get_value_from_user('Give error message:', default_error)
-            raise AssertionError(msg)
+        return status == 0

     def _get_value_from_user(message, default):
-        value = showInputDialog(None, message, DIALOG_TITLE, PLAIN_MESSAGE,
-                                None, None, default)
-        if value is None:
-            raise ValueError('No value provided by user')
-        return value
-
+        return showInputDialog(None, message, DIALOG_TITLE, PLAIN_MESSAGE,
+                               None, None, default)

 else:

@@ -94,14 +94,8 @@

     def _execute_manual_step(message, default_error):
         message += '\n\n<Yes> means PASS and <No> means FAIL.'
-        if not tkMessageBox.askyesno(DIALOG_TITLE, message):
- msg = _get_value_from_user('Give error message:', default_error)
-            raise AssertionError(msg)
+        return tkMessageBox.askyesno(DIALOG_TITLE, message)

     def _get_value_from_user(message, default):
-        value = tkSimpleDialog.askstring(DIALOG_TITLE, message,
-                                         initialvalue=default)
-        if value is None:
-            raise ValueError('No value provided by user')
-        return value
-
+        return tkSimpleDialog.askstring(DIALOG_TITLE, message,
+                                        initialvalue=default)

Modified: trunk/src/robot/libraries/Screenshot.py
==============================================================================
--- trunk/src/robot/libraries/Screenshot.py     (original)
+++ trunk/src/robot/libraries/Screenshot.py     Sun Apr 12 14:40:08 2009
@@ -27,12 +27,12 @@

 class Screenshot:

-    """This library supports taking full-screen screenshots of the desktop.
-
-    The library depends on standard Java APIs and thus requires a Jython
- runtime environment. The library does not, however, require any specific - operating system. While the library has been tested on Windows and Linux, - any operating system for which the JDK is available, should be sufficient.
+    """A test library for taking full-screen screenshots of the desktop.
+
+    `Screenshot` is Robot Framework's standard library that provides
+    keywords to capture and store screenshots of the whole desktop.
+    This library is implemented with Java AWT APIs, so it can be used
+    only when running Robot Framework on Jython.
     """

     ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

Modified: trunk/src/robot/libraries/String.py
==============================================================================
--- trunk/src/robot/libraries/String.py (original)
+++ trunk/src/robot/libraries/String.py Sun Apr 12 14:40:08 2009
@@ -16,50 +16,38 @@
 # TODO: assertions, checks, generate html and check, write internal tests
 # TODO: `` comments
# TODO: Check documentation and use short docs. Is some more examples needed?
-import os
 import re
-import shutil
-import time
-import fnmatch
-import glob
-from types import ListType
-from types import StringType
+import string as STRING
+try:
+    from random import sample
+except ImportError:   # No random.sample in Jython 2.2
+    from random import randint
+    def sample(chars, length):
+        max_index = len(chars) - 1
+        return [ chars[randint(0, max_index)] for i in xrange(length) ]

 from robot import utils
-from robot.errors import DataError
-import robot.output
-import string as STRING

-from random import Random
-#No sample method in Jython
-if utils.is_jython:
-    def _sample(self, chars, length):
-        result = ''
-        while len(result) < length:
-            result += chars[self.randint(0, len(chars)-1)]
-        return result
-
-    Random.sample = _sample

 class String:

-    """
-    This library contains keywords related to string manipulation.
+    """A test library for string manipulation and verification.

-    Following keywords from the BuiltIn library can be used with strings:
+    `String` is Robot Framework's standard library for manipulating
+    strings (e.g. `Replace String With Regexp`, `Split To Lines`) and
+    verifying their contents (e.g. `Should Be String`).

+    Following keywords from the BuiltIn library can also be used with
+    strings:
     - `Catenate`
     - `Get Length`
-    - `Grep`
+    - `Length Should Be`
     - `Should (Not) Match (Regexp)`
     - `Should (Not) Be Empty`
-    - `Should (Not) Be Equal As Strings`
+    - `Should (Not) Be Equal (As Strings)`
     - `Should (Not) Contain`
-    - `Should (Not) End With`
     - `Should (Not) Start With`
-
- From Collections library, `Length Should Be` can be used with strings as well.
-
+    - `Should (Not) End With`
     """

     ROBOT_LIBRARY_SCOPE = 'GLOBAL'
@@ -150,7 +138,7 @@
         lower and upper case letters, and digits by default.
         """
         length = self._convert_to_int(length, 'length')
-        return ''.join( Random().sample(chars, length) )
+        return ''.join(sample(chars, length))


     def get_substring(self, string, start, end=None):

Modified: trunk/src/robot/libraries/Telnet.py
==============================================================================
--- trunk/src/robot/libraries/Telnet.py (original)
+++ trunk/src/robot/libraries/Telnet.py Sun Apr 12 14:40:08 2009
@@ -23,13 +23,16 @@

 class Telnet:

- """A test library providing Telnet connections and communicating with them.
+    """A test library providing communication over Telnet connections.

-    This library supports multiple simultaneous connections, see `Open
-    Connection` and `Switch Connection` for details.
+    `Telnet` is Robot Framework's standard library that makes it
+    possible to connect to Telnet servers and execute commands on the
+    opened connections.

- The responses from the server are expected to be ASCII, all characters with
-    different encodings are ignored.
+    See `Open Connection` and `Switch Connection` for details on how
+    to handle multiple simultaneous connections. The responses are
+    expected to be ASCII encoded and all non-ASCII characters are
+    silently ignored.
     """

     ROBOT_LIBRARY_SCOPE = 'TEST_SUITE'

Reply via email to