From a30237f5f708a6d2ee6771cc83136e719358f2e0 Mon Sep 17 00:00:00 2001 From: Tattoo Date: Wed, 18 Oct 2023 15:11:24 +0300 Subject: [PATCH] Fix tests --- src/oxygen/robot3_interface.py | 2 -- src/oxygen/robot4_interface.py | 5 ++--- tests/utest/robot_interface/test_time_conversions.py | 8 +++++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/oxygen/robot3_interface.py b/src/oxygen/robot3_interface.py index 87fe6c1..e1a72f5 100644 --- a/src/oxygen/robot3_interface.py +++ b/src/oxygen/robot3_interface.py @@ -288,8 +288,6 @@ def ms_to_timestamp(self, milliseconds): tz_delta = self.get_timezone_delta() time_object = datetime.fromtimestamp(int(milliseconds / 1000)) - tz_delta - milliseconds_delta = timedelta(milliseconds=(milliseconds % 1000)) - time_object = (time_object + milliseconds_delta) if time_object.year < 1970: time_object = datetime.fromtimestamp(0) # fromtimestamp() loses milliseconds, add them back diff --git a/src/oxygen/robot4_interface.py b/src/oxygen/robot4_interface.py index a8cbc36..e4f4779 100644 --- a/src/oxygen/robot4_interface.py +++ b/src/oxygen/robot4_interface.py @@ -5,8 +5,6 @@ TestCase as RobotResultTest, TestSuite as RobotResultSuite) -from robot.model import BodyItem - from robot.running.model import TestSuite as RobotRunningSuite @@ -227,6 +225,8 @@ def spawn_robot_keyword(self, start_timestamp = self.ms_to_timestamp(start_time) end_timestamp = self.ms_to_timestamp(end_time) + # import this here so RF4 interface stays in parity with RF3 + from robot.model import BodyItem if setup: keyword_type = BodyItem.SETUP elif teardown: @@ -284,7 +284,6 @@ def timestamp_to_ms(self, timestamp): return milliseconds - def ms_to_timestamp(self, milliseconds): tz_delta = self.get_timezone_delta() diff --git a/tests/utest/robot_interface/test_time_conversions.py b/tests/utest/robot_interface/test_time_conversions.py index 660c2bb..d81bcd6 100644 --- a/tests/utest/robot_interface/test_time_conversions.py +++ b/tests/utest/robot_interface/test_time_conversions.py @@ -31,7 +31,13 @@ def test_should_be_associative(self): def _validate_timestamp(self, result): timestamp = result.ms_to_timestamp(-10) - self.assertEqual(timestamp, '19700101 02:00:00.990000') + expected = '19700101 00:00:00.990000' + # Windows 10 calculates epoch differently ( T ʖ̯ T) + import platform + if platform.system() == 'Windows' and platform.release(): + expected = '19700101 02:00:00.990000' + + self.assertEqual(timestamp, expected) def test_ms_before_epoch_are_reset_to_epoch(self): from oxygen.robot4_interface import RobotResultInterface as RF4ResultIface