如何使用相同的方法两次调用来模拟datetime.datetime.now?
在我尝试过的下面:
$lookup
答案 0 :(得分:0)
我成功了。
@patch('mypackage.dt')
def test_metodo(self, mock_date):
expected = ('2018', "2018-12-14 12:34:56")
mock_date.today.return_value = mypackage.dt(2018, 12, 14, 12, 34, 56)
mock_date.today.return_value.strftime.side_effect = list(expected)
self.assertIsNotNone(metodo())
self.assertEqual(expected, metodo())