2 new revisions:

Revision: 409d0480b216
Author:   Janne Härkönen <[email protected]>
Date:     Wed Apr 20 04:57:20 2011
Log:      BuiltIn: add argument type information logging to keywords...
http://code.google.com/p/robotframework/source/detail?r=409d0480b216

Revision: f9150d397103
Author:   Janne Härkönen <[email protected]>
Date:     Wed Apr 20 04:57:51 2011
Log:      Tests that arg type is logged with some BuiltIn kws.
http://code.google.com/p/robotframework/source/detail?r=f9150d397103

==============================================================================
Revision: 409d0480b216
Author:   Janne Härkönen <[email protected]>
Date:     Wed Apr 20 04:57:20 2011
Log:      BuiltIn: add argument type information logging to keywords

Affected keywords are:
Convert To String/Integer/Number/Boolean
Should (Not) Be Equal As Integers/Numbers/Strings
http://code.google.com/p/robotframework/source/detail?r=409d0480b216

Modified:
 /src/robot/libraries/BuiltIn.py

=======================================
--- /src/robot/libraries/BuiltIn.py     Wed Apr 20 04:24:02 2011
+++ /src/robot/libraries/BuiltIn.py     Wed Apr 20 04:57:20 2011
@@ -33,6 +33,10 @@

     def convert_to_integer(self, item):
         """Converts the given item to an integer number."""
+        self._log_types(item)
+        return self._convert_to_integer(item)
+
+    def _convert_to_integer(self, item):
         try:
             if utils.is_jython:
                 return self._jython_to_integer(item)
@@ -57,6 +61,10 @@

     def convert_to_number(self, item):
         """Converts the given item to a floating point number."""
+        self._log_types(item)
+        return self._convert_to_number(item)
+
+    def _convert_to_number(self, item):
         try:
             if utils.is_jython:
                 return self._jython_to_number(item)
@@ -64,7 +72,7 @@
         except:
             error = utils.get_error_message()
             try:
-                return float(self.convert_to_integer(item))
+                return float(self._convert_to_integer(item))
             except RuntimeError:
raise RuntimeError("'%s' cannot be converted to a floating point "
                                  "number: %s" % (item, error))
@@ -86,6 +94,10 @@
         Uses '__unicode__' or '__str__' method with Python objects and
         'toString' with Java objects.
         """
+        self._log_types(item)
+        return self._convert_to_string(item)
+
+    def _convert_to_string(self, item):
         return utils.unic(item)

     def convert_to_boolean(self, item):
@@ -96,6 +108,7 @@
         For more information about truth values, see
         http://docs.python.org/lib/truth.html.
         """
+        self._log_types(item)
         if isinstance(item, basestring):
             if utils.eq(item, 'True'):
                 return True
@@ -233,7 +246,8 @@
See `Should Be Equal` for an explanation on how to override the default
         error message with `msg` and `values`.
         """
- first, second = [ self.convert_to_integer(i) for i in first, second ]
+        self._log_types(first, second)
+ first, second = [self._convert_to_integer(i) for i in first, second]
         self._should_not_be_equal(first, second, msg, values)

def should_be_equal_as_integers(self, first, second, msg=None, values=True):
@@ -242,7 +256,8 @@
See `Should Be Equal` for an explanation on how to override the default
         error message with `msg` and `values`.
         """
- first, second = [ self.convert_to_integer(i) for i in first, second ]
+        self._log_types(first, second)
+ first, second = [self._convert_to_integer(i) for i in first, second]
         self._should_be_equal(first, second, msg, values)

def should_not_be_equal_as_numbers(self, first, second, msg=None, values=True):
@@ -253,8 +268,9 @@
See `Should Be Equal` for an explanation on how to override the default
         error message with `msg` and `values`.
         """
-        first = round(self.convert_to_number(first), 6)
-        second = round(self.convert_to_number(second), 6)
+        self._log_types(first, second)
+        first = round(self._convert_to_number(first), 6)
+        second = round(self._convert_to_number(second), 6)
         self._should_not_be_equal(first, second, msg, values)

def should_be_equal_as_numbers(self, first, second, msg=None, values=True):
@@ -265,8 +281,9 @@
See `Should Be Equal` for an explanation on how to override the default
         error message with `msg` and `values`.
         """
-        first = round(self.convert_to_number(first), 6)
-        second = round(self.convert_to_number(second), 6)
+        self._log_types(first, second)
+        first = round(self._convert_to_number(first), 6)
+        second = round(self._convert_to_number(second), 6)
         self._should_be_equal(first, second, msg, values)

def should_not_be_equal_as_strings(self, first, second, msg=None, values=True):
@@ -275,7 +292,8 @@
See `Should Be Equal` for an explanation on how to override the default
         error message with `msg` and `values`.
         """
- first, second = [ self.convert_to_string(i) for i in first, second ]
+        self._log_types(first, second)
+ first, second = [ self._convert_to_string(i) for i in first, second ]
         self._should_not_be_equal(first, second, msg, values)

def should_be_equal_as_strings(self, first, second, msg=None, values=True):
@@ -284,7 +302,8 @@
See `Should Be Equal` for an explanation on how to override the default
         error message with `msg` and `values`.
         """
- first, second = [ self.convert_to_string(i) for i in first, second ]
+        self._log_types(first, second)
+ first, second = [ self._convert_to_string(i) for i in first, second ]
         self._should_be_equal(first, second, msg, values)

     def should_not_start_with(self, str1, str2, msg=None, values=True):
@@ -519,7 +538,7 @@
         The length of the item is got using the `Get Length` keyword. The
         default error message can be overridden with the `msg` argument.
         """
-        length = self.convert_to_integer(length)
+        length = self._convert_to_integer(length)
         if self.get_length(item) != length:
             if msg is None:
                 msg = "Length of '%s' should be %d but it is %d" \
@@ -937,7 +956,7 @@
             times = times[:-5]
         elif times.endswith('x'):
             times = times[:-1]
-        times = self.convert_to_integer(times)
+        times = self._convert_to_integer(times)
         if times <= 0:
             self.log("Keyword '%s' repeated zero times" % name)
         for i in xrange(times):

==============================================================================
Revision: f9150d397103
Author:   Janne Härkönen <[email protected]>
Date:     Wed Apr 20 04:57:51 2011
Log:      Tests that arg type is logged with some BuiltIn kws.
http://code.google.com/p/robotframework/source/detail?r=f9150d397103

Modified:
 /atest/robot/standard_libraries/builtin/converter.txt
 /atest/robot/standard_libraries/builtin/verify.txt

=======================================
--- /atest/robot/standard_libraries/builtin/converter.txt Mon Apr 12 05:17:10 2010 +++ /atest/robot/standard_libraries/builtin/converter.txt Wed Apr 20 04:57:51 2011
@@ -4,26 +4,34 @@
 Default Tags    jybot  pybot
 Resource        atest_resource.txt

+*** Variables ***
+${ARG TYPES MSG}=  Argument types are:\n
+
 *** Test Cases ***
 Convert To Integer
-    Check testcase  Convert To Integer
+    ${tc}=  Check testcase  Convert To Integer
+ Check Log Message ${tc.kws[0].kws[0].msgs[0]} ${ARG TYPES MSG}<type 'unicode'>

 Convert To Integer With Java Objects
     [Tags]  jybot
-    Check testcase  Convert To Integer With Java Objects
+    ${tc}=  Check testcase  Convert To Integer With Java Objects
+ Check Log Message ${tc.kws[0].kws[0].msgs[0]} ${ARG TYPES MSG}<type 'unicode'>

 Convert To Number
-    Check testcase  Convert To Number
+    ${tc}=  Check testcase  Convert To Number
+ Check Log Message ${tc.kws[0].kws[0].msgs[0]} ${ARG TYPES MSG}<type 'unicode'>

 Convert To Number With Java Objects
     [Tags]  jybot
-    Check testcase  Convert To Number With Java Objects
+    ${tc}=  Check testcase  Convert To Number With Java Objects

 Convert To String
-    Check testcase  Convert To String
+    ${tc}=  Check testcase  Convert To String
+ Check Log Message ${tc.kws[0].msgs[0]} ${ARG TYPES MSG}<type 'unicode'>

 Convert To Boolean
-    Check testcase  Convert To Boolean
+    ${tc}=  Check testcase  Convert To Boolean
+ Check Log Message ${tc.kws[0].msgs[0]} ${ARG TYPES MSG}<type 'unicode'>

 Create List
     Check testcase  Create List
=======================================
--- /atest/robot/standard_libraries/builtin/verify.txt Wed Apr 20 03:57:25 2011 +++ /atest/robot/standard_libraries/builtin/verify.txt Wed Apr 20 04:57:51 2011
@@ -46,22 +46,28 @@
     Verify argument type message  ${tc.kws[0].msgs[0]}  unicode  long

 Should Not Be Equal As Integers
-    Check test case  ${TESTNAME}
+    ${tc}=  Check test case  ${TESTNAME}
+    Verify argument type message  ${tc.kws[0].msgs[0]}  unicode  unicode

 Should Be Equal As Integers
-    Check test case  ${TESTNAME}
+    ${tc}=  Check test case  ${TESTNAME}
+    Verify argument type message  ${tc.kws[0].msgs[0]}  unicode  unicode

 Should Not Be Equal As Numbers
-    Check test case  ${TESTNAME}
+    ${tc}=  Check test case  ${TESTNAME}
+    Verify argument type message  ${tc.kws[0].msgs[0]}  unicode  unicode

 Should Be Equal As Numbers
-    Check test case  ${TESTNAME}
+    ${tc}=  Check test case  ${TESTNAME}
+    Verify argument type message  ${tc.kws[0].msgs[0]}  unicode  unicode

 Should Not Be Equal As Strings
-    Check test case  ${TESTNAME}
+    ${tc}=  Check test case  ${TESTNAME}
+    Verify argument type message  ${tc.kws[0].msgs[0]}  unicode  float

 Should Be Equal As Strings
-    Check test case  ${TESTNAME}
+    ${tc}=  Check test case  ${TESTNAME}
+    Verify argument type message  ${tc.kws[0].msgs[0]}  long  unicode

 Should Not Start With
     Check test case  ${TESTNAME}

Reply via email to