[TIP] Can you mock a function that has a decorator applies to it?
Brianna Laugher
brianna.laugher at gmail.com
Wed Jul 4 18:01:00 PDT 2012
Hi,
On 5 July 2012 03:35, John Wong <gokoproject at gmail.com> wrote:
> There are times when decorator really shine and I don't see a way to Mock
> out the decorator. I know it replaces the current function.... is there a
> way out of this?
Can't you just call the decorator on your mocked function explicitly?
'@foo' is just syntactic sugar for 'fn = foo(fn)' anyway right?
I put a simple example with 'property' here:
https://gist.github.com/3050354
Hope that explains it, not sure if you are trying to do something more
complicated than that.
cheers
Brianna
--
They've just been waiting in a mountain for the right moment:
http://modernthings.org/
More information about the testing-in-python
mailing list