How can I proceed with a mock test in datetime.datetime.now with different calls in the same method?
In my test, the current date is returned.
Following is an example of the code to help you. Thank you in advance.
from datetime import datetime as dt
def metodo():
return dt.today().strftime('%Y'), dt.today().strftime('%Y-%m-%d %X %z')
def test_metodo(self):
expected = ('2018', "2018-12-14 12:34:56")
mock_date = Mock(spec=mypackage.metodo)
today.side_effect=list(expected)
self.assertIsNotNone(metodo())
self.assertEqual(expected, metodo())