How best to test functions which use date.today

Yuan HOng hongyuan1306 at gmail.com
Mon Mar 2 05:30:35 EST 2009


Hello,

Thanks for all the great ideas. Based on your input, I was able to solve my
problem by way of a FakeDate in a fakedate module.

In the testing module, before importing the tested module, I would load my
fakedate module into sys.modules under the key 'datetime'. So when the
tested module is imported, it will get my fakedate module in stead of the
original C-extension datetime module.

That way, the tested module needs no modification.

-- 
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090302/d78f99ec/attachment.html>


More information about the Python-list mailing list