0
How can I proceed with a mock test on datetime.datetime.now with different calls in the same method?
In my test is returned the current date.
Follow an example of the code, to facilitate help. Thanks 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())