Skip to content

Commit 28f0305

Browse files
committed
Fix tests
1 parent f1c9b29 commit 28f0305

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/oxygen/robot3_interface.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ def ms_to_timestamp(self, milliseconds):
288288
tz_delta = self.get_timezone_delta()
289289

290290
time_object = datetime.fromtimestamp(int(milliseconds / 1000)) - tz_delta
291-
milliseconds_delta = timedelta(milliseconds=(milliseconds % 1000))
292-
time_object = (time_object + milliseconds_delta)
293291
if time_object.year < 1970:
294292
time_object = datetime.fromtimestamp(0)
295293
# fromtimestamp() loses milliseconds, add them back

src/oxygen/robot4_interface.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
TestCase as RobotResultTest,
66
TestSuite as RobotResultSuite)
77

8-
from robot.model import BodyItem
9-
108
from robot.running.model import TestSuite as RobotRunningSuite
119

1210

@@ -227,6 +225,8 @@ def spawn_robot_keyword(self,
227225
start_timestamp = self.ms_to_timestamp(start_time)
228226
end_timestamp = self.ms_to_timestamp(end_time)
229227

228+
# import this here so RF4 interface stays in parity with RF3
229+
from robot.model import BodyItem
230230
if setup:
231231
keyword_type = BodyItem.SETUP
232232
elif teardown:
@@ -284,7 +284,6 @@ def timestamp_to_ms(self, timestamp):
284284

285285
return milliseconds
286286

287-
288287
def ms_to_timestamp(self, milliseconds):
289288
tz_delta = self.get_timezone_delta()
290289

tests/utest/robot_interface/test_time_conversions.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,35 @@ def setUp(self):
99

1010
def test_should_be_correct(self):
1111
timestamp = self.interface.result.ms_to_timestamp(1533625284100.0)
12-
assert timestamp == '20180807 07:01:24.100000'
12+
self.assertEqual(timestamp, '20180807 07:01:24.100000')
1313

1414
timestamp = self.interface.result.ms_to_timestamp(1533625284451.0)
15-
assert timestamp == '20180807 07:01:24.451000'
15+
self.assertEqual(timestamp, '20180807 07:01:24.451000')
1616

1717
def test_should_be_associative(self):
1818
timestamp = '20180807 07:01:24.300000'
1919

2020
milliseconds = self.interface.result.timestamp_to_ms(timestamp)
21-
assert milliseconds == 1533625284300.0
21+
self.assertEqual(milliseconds, 1533625284300.0)
2222

2323
timestamp = self.interface.result.ms_to_timestamp(milliseconds)
24-
assert timestamp == '20180807 07:01:24.300000'
24+
self.assertEqual(timestamp, '20180807 07:01:24.300000')
2525

2626
milliseconds = self.interface.result.timestamp_to_ms(timestamp)
27-
assert milliseconds == 1533625284300.0
27+
self.assertEqual(milliseconds, 1533625284300.0)
2828

2929
timestamp = self.interface.result.ms_to_timestamp(milliseconds)
30-
assert timestamp == '20180807 07:01:24.300000'
30+
self.assertEqual(timestamp, '20180807 07:01:24.300000')
3131

3232
def _validate_timestamp(self, result):
3333
timestamp = result.ms_to_timestamp(-10)
34-
self.assertEqual(timestamp, '19700101 02:00:00.990000')
34+
expected = '19700101 00:00:00.990000'
35+
# Windows 10 calculates epoch differently ( T ʖ̯ T)
36+
import platform
37+
if platform.system() == 'Windows' and platform.release() == '10':
38+
expected = '19700101 02:00:00.990000'
39+
40+
self.assertEqual(timestamp, expected)
3541

3642
def test_ms_before_epoch_are_reset_to_epoch(self):
3743
from oxygen.robot4_interface import RobotResultInterface as RF4ResultIface
@@ -47,19 +53,19 @@ def setUp(self):
4753

4854
def test_should_be_correct(self):
4955
milliseconds = self.iface.result.timestamp_to_ms('20180807 07:01:24.000')
50-
assert milliseconds == 1533625284000.0
56+
self.assertEqual(milliseconds, 1533625284000.0)
5157

5258
milliseconds = self.iface.result.timestamp_to_ms('20180807 07:01:24.555')
53-
assert milliseconds == 1533625284555.0
59+
self.assertEqual(milliseconds, 1533625284555.0)
5460

5561
def test_should_be_associative(self):
5662
milliseconds = 1533625284300.0
5763

5864
timestamp = self.iface.result.ms_to_timestamp(milliseconds)
59-
assert timestamp == '20180807 07:01:24.300000'
65+
self.assertEqual(timestamp, '20180807 07:01:24.300000')
6066

6167
milliseconds = self.iface.result.timestamp_to_ms(timestamp)
62-
assert milliseconds == 1533625284300.0
68+
self.assertEqual(milliseconds, 1533625284300.0)
6369

6470
timestamp = self.iface.result.ms_to_timestamp(milliseconds)
65-
assert timestamp == '20180807 07:01:24.300000'
71+
self.assertEqual(timestamp, '20180807 07:01:24.300000')

0 commit comments

Comments
 (0)