def test_write_timestamp_file(self, mock_dt):
"""
Assert a TaskRunner calls write_json with the expected args. Implicitly testing that we are using datetime.isoformat to derive
the value for the "RUN" key.
:param mock_dt: ??? not sure this patch is necessary
"""
fake_date_str = "not iso formatted"
mock_datetime_obj = mock.MagicMock()
mock_datetime_obj.isoformat = mock.MagicMock(return_value=fake_date_str)
mock_dt.datetime.now = mock.MagicMock(return_value=mock_datetime_obj)
self.task_runner_instance.write_json = mock.MagicMock()
self.task_runner_instance.write_timestamp_file()
self.task_runner_instance.write_json.assert_called_once_with({'RUN': fake_date_str})
评论列表
文章目录