datetime.datetime.now()
'un sınama amacıyla belirli bir datetime döndürdüğünden emin olmak isterim. Bunu nasıl yaparım? Ben pytest en monkeypatchYerleşik işlev nasıl maymunlanır datetime.datetime.now?
monkeypatch.setattr(datetime.datetime,"now", nowfunc)
ile denedim Ama bu hata gösterdiği gibi, bana hata TypeError: can't set attributes of built-in/extension type 'datetime.datetime'
doğru bağlanmış. İşte py.test için güzel ve eksiksiz bir çözüm: http://stackoverflow.com/questions/20503373/how-to-monkeypatch-pythons-datetime-datetime-now-with-py-test –