Replacing module with a stub for unit testing

s4g rafalskiy at gmail.com
Fri May 29 16:43:45 EDT 2009


Try

import sys
import ExpensiveModuleStub

sys.modules['ExpensiveModule'] = ExpensiveModuleStub
sys.modules['ExpensiveModule'].__name__ = 'ExpensiveModule'

Should do the trick


------
Vyacheslav



More information about the Python-list mailing list