3 new revisions:

Revision: fff210ee1976
Author:   Pekka Klärck
Date:     Thu Aug 16 00:32:13 2012
Log:      added empty line between functions
http://code.google.com/p/robotframework/source/detail?r=fff210ee1976

Revision: ea8ec237e6ce
Author:   Pekka Klärck
Date:     Thu Aug 16 01:03:44 2012
Log: report & log: Don't use bold font with log/report links because it loo...
http://code.google.com/p/robotframework/source/detail?r=ea8ec237e6ce

Revision: 1a0462c9a285
Author:   Pekka Klärck
Date:     Thu Aug 16 04:46:52 2012
Log: utils.elapsed_time_to_string: Support for returning string w/o millise...
http://code.google.com/p/robotframework/source/detail?r=1a0462c9a285

==============================================================================
Revision: fff210ee1976
Author:   Pekka Klärck
Date:     Thu Aug 16 00:32:13 2012
Log:      added empty line between functions
http://code.google.com/p/robotframework/source/detail?r=fff210ee1976

Modified:
 /src/robot/htmldata/rebot/report.html

=======================================
--- /src/robot/htmldata/rebot/report.html       Mon Aug 13 04:30:17 2012
+++ /src/robot/htmldata/rebot/report.html       Thu Aug 16 00:32:13 2012
@@ -178,6 +178,7 @@
         $('#print_selector').text(suite.name);
     });
 }
+
 function scrollToSelector(anchor) {
     $('#test_details_container').css('min-height', $(window).height());
     window.prevLocationHash = "#"+anchor;

==============================================================================
Revision: ea8ec237e6ce
Author:   Pekka Klärck
Date:     Thu Aug 16 01:03:44 2012
Log: report & log: Don't use bold font with log/report links because it looks crap in Firefox (at least on my WinXP).

The non-bold version is at least as good as the bold version with Chrome and IE.
http://code.google.com/p/robotframework/source/detail?r=ea8ec237e6ce

Modified:
 /src/robot/htmldata/rebot/common.css

=======================================
--- /src/robot/htmldata/rebot/common.css        Thu May 31 05:05:46 2012
+++ /src/robot/htmldata/rebot/common.css        Thu Aug 16 01:03:44 2012
@@ -67,7 +67,6 @@
     right: 0;
     z-index: 1000;
     width: 12em;
-    font-weight: bold;
     text-align: center;
 }
 #report_or_log_link a {

==============================================================================
Revision: 1a0462c9a285
Author:   Pekka Klärck
Date:     Thu Aug 16 04:46:52 2012
Log: utils.elapsed_time_to_string: Support for returning string w/o milliseconds.

This was needed to add elapsed time (without millis) to statistics in log/report (issue 1194).
Also added unit tests for normal elapsed_time_to_string usage.

Update issue 1194
Status: Started
Owner: pekka.klarck
Started to work with the back-end.
http://code.google.com/p/robotframework/source/detail?r=1a0462c9a285

Modified:
 /src/robot/utils/robottime.py
 /utest/utils/test_robottime.py

=======================================
--- /src/robot/utils/robottime.py       Thu Jun  7 22:57:14 2012
+++ /src/robot/utils/robottime.py       Thu Aug 16 04:46:52 2012
@@ -311,19 +311,30 @@
     return int(end_millis - start_millis)


-def elapsed_time_to_string(elapsed_millis):
-    """Converts elapsed time in millisecods to format 'hh:mm:ss.mil'"""
-    elapsed_millis = round(elapsed_millis)
-    if elapsed_millis < 0:
-        pre = '-'
-        elapsed_millis = abs(elapsed_millis)
-    else:
-        pre = ''
-    millis = elapsed_millis % 1000
-    secs  = int(elapsed_millis / 1000) % 60
-    mins  = int(elapsed_millis / 60000) % 60
-    hours = int(elapsed_millis / 3600000)
-    return '%s%02d:%02d:%02d.%03d' % (pre, hours, mins, secs, millis)
+def elapsed_time_to_string(elapsed, include_millis=True):
+    """Converts elapsed time in milliseconds to format 'hh:mm:ss.mil'.
+
+    If `include_millis` is True, '.mil' part is omitted.
+    """
+    prefix = ''
+    if elapsed < 0:
+        elapsed = abs(elapsed)
+        prefix = '-'
+    if include_millis:
+        return prefix + _elapsed_time_to_string(elapsed)
+    return prefix + _elapsed_time_to_string_without_millis(elapsed)
+
+def _elapsed_time_to_string(elapsed):
+    secs, millis = divmod(int(round(elapsed)), 1000)
+    mins, secs = divmod(secs, 60)
+    hours, mins = divmod(mins, 60)
+    return '%02d:%02d:%02d.%03d' % (hours, mins, secs, millis)
+
+def _elapsed_time_to_string_without_millis(elapsed):
+    secs = int(round(elapsed, -3)) / 1000
+    mins, secs = divmod(secs, 60)
+    hours, mins = divmod(mins, 60)
+    return '%02d:%02d:%02d' % (hours, mins, secs)


 def _timestamp_to_millis(timestamp, seps=None):
=======================================
--- /utest/utils/test_robottime.py      Tue Jun  5 03:22:50 2012
+++ /utest/utils/test_robottime.py      Thu Aug 16 04:46:52 2012
@@ -9,7 +9,8 @@
from robot.utils.robottime import (timestr_to_secs, secs_to_timestr, get_time, parse_time, format_time, get_elapsed_time,
                                    get_timestamp, get_start_timestamp,
-                                   timestamp_to_secs, _get_timetuple)
+ timestamp_to_secs, elapsed_time_to_string,
+                                   _get_timetuple)


EXAMPLE_TIME = time.mktime(datetime.datetime(2007, 9, 20, 16, 15, 14).timetuple())
@@ -170,6 +171,57 @@
             actual = get_elapsed_time(starttime, endtime)
             assert_equal(actual, expected, endtime)

+    def test_elapsed_time_to_string(self):
+        for elapsed, expected in [(0, '00:00:00.000'),
+                                  (0.1, '00:00:00.000'),
+                                  (0.49999, '00:00:00.000'),
+                                  (0.5, '00:00:00.001'),
+                                  (1, '00:00:00.001'),
+                                  (42, '00:00:00.042'),
+                                  (999, '00:00:00.999'),
+                                  (999.9, '00:00:01.000'),
+                                  (1000, '00:00:01.000'),
+                                  (1001, '00:00:01.001'),
+                                  (60000, '00:01:00.000'),
+                                  (600000, '00:10:00.000'),
+                                  (654321, '00:10:54.321'),
+                                  (660000, '00:11:00.000'),
+                                  (3600000, '01:00:00.000'),
+                                  (36000000, '10:00:00.000'),
+                                  (360000000, '100:00:00.000'),
+                                  (360000000 + 36000000 + 3600000 +
+                                   660000 + 11111, '111:11:11.111')]:
+ assert_equal(elapsed_time_to_string(elapsed), expected, elapsed)
+            if expected != '00:00:00.000':
+                assert_equal(elapsed_time_to_string(-1 * elapsed),
+                             '-' + expected, elapsed)
+
+    def test_elapsed_time_to_string_without_millis(self):
+        for elapsed, expected in [(0, '00:00:00'),
+                                  (1, '00:00:00'),
+                                  (499, '00:00:00'),
+                                  (499.999, '00:00:00'),
+                                  (500, '00:00:01'),
+                                  (999, '00:00:01'),
+                                  (1000, '00:00:01'),
+                                  (1499, '00:00:01'),
+                                  (59499.9, '00:00:59'),
+                                  (59500.0, '00:01:00'),
+                                  (59999, '00:01:00'),
+                                  (60000, '00:01:00'),
+                                  (654321, '00:10:54'),
+                                  (654500, '00:10:55'),
+                                  (3599999, '01:00:00'),
+                                  (3600000, '01:00:00'),
+                                  (359999999, '100:00:00'),
+                                  (360000000, '100:00:00'),
+                                  (360000500, '100:00:01')]:
+ assert_equal(elapsed_time_to_string(elapsed, include_millis=False),
+                         expected, elapsed)
+            if expected != '00:00:00':
+                assert_equal(elapsed_time_to_string(-1 * elapsed, False),
+                             '-' + expected, elapsed)
+
     def test_parse_modified_time_with_valid_times(self):
         for input, expected in [('100', 100),
                                 ('2007-09-20 16:15:14', EXAMPLE_TIME),

Reply via email to