On May 23, 2:00 pm, pigmart...@gmail.com wrote:
> Hi,
>
> I'm working on a unit test framework for a module. The module I'm
> testing indirectly calls another module which is expensive to access
> --- CDLLs whose functions access a database.
>
> test_MyModule --->MyModule--->IntermediateModule
Try
import sys
import ExpensiveModuleStub
sys.modules['ExpensiveModule'] = ExpensiveModuleStub
sys.modules['ExpensiveModule'].__name__ = 'ExpensiveModule'
Should do the trick
--
Vyacheslav
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 24 May 2009 13:14:30 +0100, A. Cavallo wrote:
> how about the old and simple:
>
> import ExpensiveModuleStub as ExpensiveModule
No, that won't do, because for it to have the desired effort, it needs to
be inside the IntermediateModule, not the Test_Module. That means that
IntermediateM
how about the old and simple:
import ExpensiveModuleStub as ExpensiveModule
On a different league you could make use of decorator and creating caching
objects but that depends entirely on the requirements (how strict your test
must be, test data sizes involved and more, much more details).
Rega
pigmart...@gmail.com writes:
>
> import ExpensiveModuleStub
> sys.modules['ExpensiveModule'] = ExpensiveModuleStub # Doesn't
> work
>
> But, import statements in the IntermediateModule still access the real
> ExpensiveModule, not the stub.
>
> The examples I can find of creating and usi
On Sat, 23 May 2009 06:00:15 -0700, pigmartian wrote:
> Hi,
>
> I'm working on a unit test framework for a module. The module I'm
> testing indirectly calls another module which is expensive to access ---
> CDLLs whose functions access a database.
...
> The examples I can find of creating and us