I\'m trying to write tests for a class that has methods like:
import datetime import pytz class MyClass: def get_now(self, timezone): return dat
If you don't want to install anything this is the simplest way. Simply use, Mock class -
class NewDt(datetime.date): @classmethod def now(cls): return datetime.datetime.strptime('2020-07-10 05:20:20', '%Y-%m-%d %H:%M:%S')
And use this patch before mock function
@mock.patch('module path', NewDt)