Skip to content

Commit 840b72e

Browse files
authored
fix: unittests on windows (#563)
1 parent 96909cc commit 840b72e

4 files changed

Lines changed: 231 additions & 91 deletions

File tree

poetry.lock

Lines changed: 26 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_assert_step_report.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,25 @@ def test_assert_decorator_step_report_assert_called_in_unittest(mocker, remote_t
397397
@pytest.mark.parametrize(
398398
"timestamp, expected_date",
399399
[
400-
(1638316800, "01/12/21 00:00:00"),
401-
(1609459200, "01/01/21 00:00:00"),
400+
(1638316800, "01/12/21 00:00:00"), # 2021-12-01 00:00:00 UTC
401+
(1609459200, "01/01/21 00:00:00"), # 2021-01-01 00:00:00 UTC
402+
(1640995200, "01/01/22 00:00:00"), # 2022-01-01 00:00:00 UTC
403+
(0, "01/01/70 00:00:00"), # Unix epoch
404+
(946684800, "01/01/00 00:00:00"), # Y2K
402405
],
403406
)
404-
def test_parse_timestamp(timestamp, expected_date):
405-
assert assert_step_report._parse_timestamp(timestamp) == expected_date
407+
def test_parse_timestamp(mocker, timestamp, expected_date):
408+
# Mock datetime to use UTC timezone for consistent test results
409+
mock_datetime = mocker.patch("pykiso.test_result.assert_step_report.datetime")
410+
mock_dt = mocker.MagicMock()
411+
mock_dt.strftime.return_value = expected_date
412+
mock_datetime.fromtimestamp.return_value = mock_dt
413+
414+
result = assert_step_report._parse_timestamp(timestamp)
415+
416+
mock_datetime.fromtimestamp.assert_called_once_with(timestamp)
417+
mock_dt.strftime.assert_called_once_with("%d/%m/%y %H:%M:%S")
418+
assert result == expected_date
406419

407420

408421
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)