On Feb 28, 5:54 pm, Lie Ryan wrote:
> Yuan HOng wrote:
> > HI,
>
> > In my project I have several date related methods which I want tested for
> > correctness. The functions use date.today() in several places. Since this
> > could change every time I run the test, I hope to find someway to fake a
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
Lie Ryan wrote:
Yuan HOng wrote:
In my project I have several date related methods which I want tested for
correctness. The functions use date.today() in several places. Since this
could change every time I run the test, I hope to find someway to fake a
date.today.
For illustration lets say I ha
En Sat, 28 Feb 2009 15:35:47 -0200, Yuan HOng
escribió:
In my project I have several date related methods which I want tested for
correctness. The functions use date.today() in several places. Since this
could change every time I run the test, I hope to find someway to fake a
date.today.
For
Christian Heimes wrote:
> Lie Ryan wrote:
> >> But this fails with:
> >>
> >> TypeError: can't set attributes of built-in/extension type
> >> 'datetime.date'
> >
> > This is because today is an attribute. In python, we can override
> > attribute access to become a function call. I don't have pyth
Lie Ryan wrote:
>> But this fails with:
>>
>> TypeError: can't set attributes of built-in/extension type
>> 'datetime.date'
>
> This is because today is an attribute. In python, we can override
> attribute access to become a function call. I don't have python right
> now, but try this:
>
> del da
Yuan HOng wrote:
HI,
In my project I have several date related methods which I want tested for
correctness. The functions use date.today() in several places. Since this
could change every time I run the test, I hope to find someway to fake a
date.today.
For illustration lets say I have a functi
HI,
In my project I have several date related methods which I want tested for
correctness. The functions use date.today() in several places. Since this
could change every time I run the test, I hope to find someway to fake a
date.today.
For illustration lets say I have a function:
from datetime