4 new revisions:

Revision: abb0ea4a947a
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:09:44 2014 UTC
Log:      add '.' at the end of error about invalid time string
http://code.google.com/p/robotframework/source/detail?r=abb0ea4a947a

Revision: 967bd8adf309
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:21:42 2014 UTC
Log:      atest/genrunner.py: extra column headers on test case heading row
http://code.google.com/p/robotframework/source/detail?r=967bd8adf309

Revision: b8eabaec3dfe
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:22:40 2014 UTC
Log:      Started development of new DataTime library....
http://code.google.com/p/robotframework/source/detail?r=b8eabaec3dfe

Revision: e187a79d1ce6
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:23:49 2014 UTC
Log:      merge
http://code.google.com/p/robotframework/source/detail?r=e187a79d1ce6

==============================================================================
Revision: abb0ea4a947a
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:09:44 2014 UTC
Log:      add '.' at the end of error about invalid time string
http://code.google.com/p/robotframework/source/detail?r=abb0ea4a947a

Modified:
 /atest/testdata/core/test_and_uk_settings.html
 /atest/testdata/standard_libraries/builtin/sleep.txt
 /atest/testdata/standard_libraries/builtin/wait_until_keyword_succeeds.txt
 /atest/testdata/standard_libraries/operating_system/modified_time.txt
/atest/testdata/standard_libraries/operating_system/wait_until_removed_created.txt
 /src/robot/utils/robottime.py
 /utest/running/test_timeouts.py
 /utest/utils/test_robottime.py

=======================================
--- /atest/testdata/core/test_and_uk_settings.html Sun Jun 9 20:21:57 2013 UTC +++ /atest/testdata/core/test_and_uk_settings.html Fri Apr 25 13:09:44 2014 UTC
@@ -801,7 +801,7 @@
       <td>[ Document ]</td>
       <td>FAIL</td>
       <td>Setup failed:\n<br>
-Setting test timeout failed: Invalid time string 'invalid'</td>
+Setting test timeout failed: Invalid time string 'invalid'.</td>
       <td></td>
     </tr>
     <tr>
@@ -1165,7 +1165,7 @@
       <td>User Keyword With Invalid Timeout</td>
       <td>[ Document ]</td>
       <td>FAIL</td>
- <td>Setting keyword timeout failed: Invalid time string 'invalid uk'</td> + <td>Setting keyword timeout failed: Invalid time string 'invalid uk'.</td>
       <td></td>
     </tr>
     <tr>
=======================================
--- /atest/testdata/standard_libraries/builtin/sleep.txt Mon Dec 12 14:33:59 2011 UTC +++ /atest/testdata/standard_libraries/builtin/sleep.txt Fri Apr 25 13:09:44 2014 UTC
@@ -20,7 +20,7 @@
     Sleep    42 ms    No good reason

 Invalid Time Does Not Cause Uncatchable Error
- Run Keyword And Expect Error ValueError: Invalid time string 'invalid time' Sleep invalid time + Run Keyword And Expect Error ValueError: Invalid time string 'invalid time'. Sleep invalid time

 Can Stop Sleep With Timeout
     [Documentation]    FAIL Test timeout 10 milliseconds exceeded.
=======================================
--- /atest/testdata/standard_libraries/builtin/wait_until_keyword_succeeds.txt Fri Nov 22 13:11:15 2013 UTC +++ /atest/testdata/standard_libraries/builtin/wait_until_keyword_succeeds.txt Fri Apr 25 13:09:44 2014 UTC
@@ -26,11 +26,11 @@
Should Be Equal ${return value} ${HELLO} Returned value should be the one that is given to the keyword.

 Invalid Timeout Does Not Cause Uncatchable Failure
- Run Keyword And Expect Error ValueError: Invalid time string 'Not Time Value' + Run Keyword And Expect Error ValueError: Invalid time string 'Not Time Value'. ... Wait Until Keyword Succeeds Not Time Value 1 seconds No Operation

 Invalid Retry Interval Does Not Cause Uncatchable Failure
-    Run Keyword And Expect Error  ValueError: Invalid time string 'invalid'
+ Run Keyword And Expect Error ValueError: Invalid time string 'invalid'.
     ...  Wait Until Keyword Succeeds  1 seconds  invalid  No Operation

 Wait Until In User Keyword
=======================================
--- /atest/testdata/standard_libraries/operating_system/modified_time.txt Tue Jan 29 00:31:28 2013 UTC +++ /atest/testdata/standard_libraries/operating_system/modified_time.txt Fri Apr 25 13:09:44 2014 UTC
@@ -59,7 +59,7 @@
     Set Modified Time  ${TESTFILE}  invalid

 Set Modified Time Using NOW
- [Documentation] FAIL Setting modified time of '${TESTFILE}' failed: Invalid time string 'invalid' + [Documentation] FAIL Setting modified time of '${TESTFILE}' failed: Invalid time string 'invalid'.
     Create File  ${TESTFILE}
     ${t0} =  Get Modified Time  ${TESTFILE}  epoch
     Sleep  2.5 s
=======================================
--- /atest/testdata/standard_libraries/operating_system/wait_until_removed_created.txt Wed May 25 14:40:46 2011 UTC +++ /atest/testdata/standard_libraries/operating_system/wait_until_removed_created.txt Fri Apr 25 13:09:44 2014 UTC
@@ -52,7 +52,7 @@
     Wait Until Removed  ${BOTH PATTERN}  0.042

 Invalid Remove Timeout
-    [Documentation]  FAIL ValueError: Invalid time string 'invalid timeout'
+ [Documentation] FAIL ValueError: Invalid time string 'invalid timeout'.
     Wait Until Removed  non-existing  invalid timeout

 File And Dir Already Created
@@ -85,7 +85,7 @@
     Wait Until Created  ${BOTH PATTERN}  0.022

 Invalid Create Timeout
-    [Documentation]  FAIL ValueError: Invalid time string 'invalid timeout'
+ [Documentation] FAIL ValueError: Invalid time string 'invalid timeout'.
     Wait Until Created  ${CURDIR}  invalid timeout

 *** Keywords ***
=======================================
--- /src/robot/utils/robottime.py       Thu Jan 23 14:00:53 2014 UTC
+++ /src/robot/utils/robottime.py       Fri Apr 25 13:09:44 2014 UTC
@@ -53,7 +53,7 @@
     try:
         secs = _timestr_to_secs(timestr)
     except (ValueError, TypeError):
-        raise ValueError("Invalid time string '%s'" % timestr)
+        raise ValueError("Invalid time string '%s'." % timestr)
     return round(secs, 3)

 def _timestr_to_secs(timestr):
=======================================
--- /utest/running/test_timeouts.py     Sat Dec 10 21:00:58 2011 UTC
+++ /utest/running/test_timeouts.py     Fri Apr 25 13:09:44 2014 UTC
@@ -34,7 +34,7 @@
         for inv in ['invalid', '1s 1']:
             for params in [ [inv], [inv,'whatever'] ]:
                 tout = TestTimeout(*params)
- err = "Setting test timeout failed: Invalid time string '%s'" + err = "Setting test timeout failed: Invalid time string '%s'." self._verify_tout(tout, str=inv, secs=0.000001, err=err % inv)

     def _verify_tout(self, tout, str='', secs=-1, err=None):
=======================================
--- /utest/utils/test_robottime.py      Mon Oct 28 19:09:22 2013 UTC
+++ /utest/utils/test_robottime.py      Fri Apr 25 13:09:44 2014 UTC
@@ -75,7 +75,7 @@

     def test_timestr_to_secs_invalid(self):
         for inv in ['', 'foo', '1sec 42 millis 3', '1min 2w', None]:
- assert_raises_with_msg(ValueError, "Invalid time string '%s'" % inv, + assert_raises_with_msg(ValueError, "Invalid time string '%s'." % inv,
                                    timestr_to_secs, inv)

     def test_secs_to_timestr(self):
@@ -251,9 +251,9 @@
for value, msg in [("-100", "Epoch time must be positive (got -100)"),
                            ("YYYY-MM-DD hh:mm:ss",
                             "Invalid time format 'YYYY-MM-DD hh:mm:ss'"),
-                           ("now + foo", "Invalid time string 'foo'"),
-                           ("now -    2a ", "Invalid time string '2a'"),
-                           ("now+", "Invalid time string ''"),
+                           ("now + foo", "Invalid time string 'foo'."),
+                           ("now -    2a ", "Invalid time string '2a'."),
+                           ("now+", "Invalid time string ''."),
                            ("nowadays", "Invalid time format 'nowadays'")]:
             assert_raises_with_msg(ValueError, msg, parse_time, value)


==============================================================================
Revision: 967bd8adf309
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:21:42 2014 UTC
Log:      atest/genrunner.py: extra column headers on test case heading row
http://code.google.com/p/robotframework/source/detail?r=967bd8adf309

Modified:
 /atest/genrunner.py

=======================================
--- /atest/genrunner.py Thu Nov 28 14:22:03 2013 UTC
+++ /atest/genrunner.py Fri Apr 25 13:21:42 2014 UTC
@@ -28,7 +28,7 @@
     for line in input.readlines():
         line = line.rstrip()
         if line.startswith('*'):
-            name = line.replace('*', '').replace(' ', '').upper()
+ name = line.split(' ')[0].replace('*', '').replace(' ', '').upper()
             process = name in ('TESTCASE', 'TESTCASES')
         elif process and line and line[0] != ' ':
             TESTS.append(line.split('  ')[0])

==============================================================================
Revision: b8eabaec3dfe
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:22:40 2014 UTC
Log:      Started development of new DataTime library.

Update issue 415
Status: Started
Implemented "Convert Time" keyword.
http://code.google.com/p/robotframework/source/detail?r=b8eabaec3dfe

Added:
 /atest/robot/standard_libraries/datetime/convert_time_input_format.txt
 /atest/robot/standard_libraries/datetime/convert_time_result_format.txt
 /atest/testdata/standard_libraries/datetime/convert_time_input_format.txt
 /atest/testdata/standard_libraries/datetime/convert_time_result_format.txt
 /atest/testdata/standard_libraries/datetime/datesandtimes.py
 /src/robot/libraries/DateTime.py
Modified:
 /doc/libraries/lib2html.py
 /src/robot/running/namespace.py

=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/datetime/convert_time_input_format.txt Fri Apr 25 13:22:40 2014 UTC
@@ -0,0 +1,26 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY} standard_libraries/datetime/convert_time_input_format.txt
+Force Tags       regression    pybot    jybot
+Resource         atest_resource.txt
+
+*** Test Cases ***
+Time string
+    Check Test Case    ${TESTNAME}
+
+Number as string
+    Check Test Case    ${TESTNAME}
+
+Number
+    Check Test Case    ${TESTNAME}
+
+Clock
+    Check Test Case    ${TESTNAME}
+
+Clock without millis
+    Check Test Case    ${TESTNAME}
+
+Timedelta
+    Check Test Case    ${TESTNAME}
+
+Invalid
+    Check Test Case    ${TESTNAME}
=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/datetime/convert_time_result_format.txt Fri Apr 25 13:22:40 2014 UTC
@@ -0,0 +1,26 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY} standard_libraries/datetime/convert_time_result_format.txt
+Force Tags       regression    pybot    jybot
+Resource         atest_resource.txt
+
+*** Test Cases ***
+Convert to seconds
+    Check Test Case    ${TESTNAME}
+
+Convert to string
+    Check Test Case    ${TESTNAME}
+
+Convert to compact string
+    Check Test Case    ${TESTNAME}
+
+Convert to clock
+    Check Test Case    ${TESTNAME}
+
+Convert to timedelta
+    Check Test Case    ${TESTNAME}
+
+Ignore millis
+    Check Test Case    ${TESTNAME}
+
+Invalid format
+    Check Test Case    ${TESTNAME}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/datetime/convert_time_input_format.txt Fri Apr 25 13:22:40 2014 UTC
@@ -0,0 +1,53 @@
+*** Settings ***
+Test Template     Time conversion should succeed
+Library           DateTime
+Variables         datesandtimes.py
+
+*** Test Cases ***    INPUT                                 EXPECTED
+Time string           10 s                                  10
+                      0.5 seconds                           0.5
+                      1d 2h 3m 4s 5ms                       93784.005
+                      1 day 2 hours 3 min 4 sec 5 millis    93784.005
+                      999.9 milliseconds                    1
+                      -10s                                  -10
+                      - 1 min 0.5 sec                       -60.5
+                      0 days 2 mins 0 s                     120
+                      0 s                                   0
+
+Number as string      10                                    10
+                      0.5                                   0.5
+                      -1                                    -1
+                      0                                     0
+
+Number                ${42}                                 42
+                      ${3.14}                               3.14
+                      ${-0.5}                               -0.5
+                      ${0}                                  0
+
+Clock                 00:00:00.000                          0
+                      00:00:00.001                          0.001
+                      00:00:01.000                          1
+                      01:02:03.004                          3723.004
+                      99:59:59.999                          359999.999
+                      100:00:00.000                         360000
+
+Clock without millis
+                      00:00:00                              0
+                      00:00:01                              1
+                      01:02:03                              3723
+                      99:59:59                              359999
+                      100:00:00                             360000
+
+Timedelta             ${timedelta(1)}                       86400
+                      ${timedelta(seconds=1.5)}             1.5
+                      ${timedelta(hours=-1)}                -3600
+
+Invalid [Documentation] FAIL ValueError: Invalid time string 'kekkonen'.
+                      kekkonen                              0
+
+*** Keywords ***
+Time conversion should succeed
+    [Arguments]    ${input}    ${expected}
+    ${expected} =    Convert To Number    ${expected}
+    ${result} =    Convert Time    ${input}
+    Should Be Equal    ${result}    ${expected}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/datetime/convert_time_result_format.txt Fri Apr 25 13:22:40 2014 UTC
@@ -0,0 +1,48 @@
+*** Settings ***
+Test Template     Time conversion should succeed
+Library           DateTime
+Variables         datesandtimes.py
+
+*** Test Cases ***    INPUT              FORMAT       EXPECTED
+Convert to seconds    10 s               number       ${10}
+                      ${-62.3}           NUMBER       ${-62.3}
+                      ${timedelta(2)}    NUMber       ${172800}
+
+Convert to string     10 s               verbose      10 seconds
+ ${-62.3} VERBOSE - 1 minute 2 seconds 300 milliseconds
+                      ${timedelta(2)}    VERbose      2 days
+
+Convert to compact string
+                      10 s               compact      10s
+                      ${-62.3}           COMPACT      - 1min 2s 300ms
+                      ${timedelta(2)}    COMpact      2d
+
+Convert to clock      10 s               clock        00:00:10.000
+                      ${-62.3}           CLOCK        -00:01:02.300
+                      ${timedelta(5)}    CLock        120:00:00.000
+
+Convert to timedelta
+ 10 s timedelta ${timedelta(seconds=10)} + ${-62.3} TIMEDELTA ${timedelta(minutes=-1, seconds=-2.3)}
+                      ${timedelta(2)}    TIMEdelta    ${timedelta(2)}
+
+Ignore millis [Template] Time conversion without millis should succeed
+                      61.5               number       ${62}
+                      61.5               verbose      1 minute 2 seconds
+                      61.5               compact      1min 2s
+                      61.5               clock        00:01:02
+ 61.5 timedelta ${timedelta(seconds=62)}
+
+Invalid format [Documentation] FAIL ValueError: Unknown format 'invalid'.
+                      10s                invalid      0
+
+*** Keywords ***
+Time conversion should succeed
+    [Arguments]    ${input}    ${format}    ${expected}
+    ${result} =    Convert Time    ${input}    ${format}
+    Should Be Equal    ${result}    ${expected}
+
+Time conversion without millis should succeed
+    [Arguments]    ${input}    ${format}    ${expected}
+ ${result} = Convert Time ${input} ${format} exclude_millis=Yes
+    Should Be Equal    ${result}    ${expected}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/datetime/datesandtimes.py Fri Apr 25 13:22:40 2014 UTC
@@ -0,0 +1,2 @@
+from datetime import timedelta
+
=======================================
--- /dev/null
+++ /src/robot/libraries/DateTime.py    Fri Apr 25 13:22:40 2014 UTC
@@ -0,0 +1,57 @@
+from datetime import timedelta
+import re
+
+from robot.utils import elapsed_time_to_string, secs_to_timestr, timestr_to_secs
+
+
+class DateTime(object):
+
+ def convert_time(self, time, result_format='number', exclude_millis=False):
+        return Time(time).convert(result_format, millis=not exclude_millis)
+
+
+class Time(object):
+    _clock_re = re.compile('(\d{2,}):(\d{2}):(\d{2})(\.(\d{3}))?')
+
+    def __init__(self, time):
+        self.seconds = self._convert_time_to_seconds(time)
+
+    def _convert_time_to_seconds(self, time):
+        if isinstance(time, timedelta):
+            return time.total_seconds()
+        if isinstance(time, basestring):
+            match = self._clock_re.match(time)
+            if match:
+                return self._convert_clock_to_secs(match)
+        return timestr_to_secs(time)
+
+    def _convert_clock_to_secs(self, match):
+        hours, minutes, seconds, millis_included, millis = match.groups()
+        result = 60 * 60 * int(hours) + 60 * int(minutes) + int(seconds)
+        print match.groups()
+        if millis_included:
+            result += int(millis) / 1000.0
+        return result
+
+    def convert(self, format, millis=True):
+        try:
+ result_converter = getattr(self, '_convert_to_%s' % format.lower())
+        except AttributeError:
+            raise ValueError("Unknown format '%s'." % format)
+        seconds = self.seconds if millis else int(round(self.seconds))
+        return result_converter(seconds, millis)
+
+    def _convert_to_number(self, seconds, millis=True):
+        return seconds
+
+    def _convert_to_verbose(self, seconds, millis=True):
+        return secs_to_timestr(seconds)
+
+    def _convert_to_compact(self, seconds, millis=True):
+        return secs_to_timestr(seconds, compact=True)
+
+    def _convert_to_clock(self, seconds, millis=True):
+ return elapsed_time_to_string(seconds * 1000, include_millis=millis)
+
+    def _convert_to_timedelta(self, seconds, millis=True):
+        return timedelta(seconds=seconds)
=======================================
--- /doc/libraries/lib2html.py  Wed Apr 24 12:32:33 2013 UTC
+++ /doc/libraries/lib2html.py  Fri Apr 25 13:22:40 2014 UTC
@@ -5,6 +5,7 @@
 Libraries:
   BuiltIn (bu)
   Collections (co)
+  DateTime (da)
   Dialogs (di)
   OperatingSystem (op)
   Process (pr)
=======================================
--- /src/robot/running/namespace.py     Thu Jan 23 14:00:53 2014 UTC
+++ /src/robot/running/namespace.py     Fri Apr 25 13:22:40 2014 UTC
@@ -29,7 +29,7 @@
 from .context import EXECUTION_CONTEXTS


-STDLIB_NAMES = set(('BuiltIn', 'Collections', 'Dialogs', 'Easter',
+STDLIB_NAMES = set(('BuiltIn', 'Collections', 'DateTime', 'Dialogs', 'Easter',
                     'OperatingSystem', 'Process', 'Remote', 'Reserved',
                     'Screenshot', 'String', 'Telnet', 'XML'))
 IMPORTER = Importer()

==============================================================================
Revision: e187a79d1ce6
Branch:   default
Author:   Pekka Klärck
Date:     Fri Apr 25 13:23:49 2014 UTC
Log:      merge
http://code.google.com/p/robotframework/source/detail?r=e187a79d1ce6


--

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