I want to simulate MyApp that imports a module (ResourceX) which requires a resource that is not available at the time and will not work. 
A solution for this is to make and import a mock module of ResourceX (named ResourceXSimulated) and divert it to MyApp as ResourceX. I want to do this in order to avoid breaking a lot of code and get all kinds of exception from MyApp.
I am using Python and It should be something like:
"Import ResourceXSimulated as ResourceX"
"ResourceX.getData()", actually calls ResourceXSimultated.getData()
Looking forward to find out if Python supports this kind of redirection.
Cheers.
ADDITIONAL INFO: I have access to the source files.
UPDATE: I am thinking of adding as little code as possible to MyApp regarding using the fake module and add this code near the import statements.
Yes, it's possible. Some starters:
You can "divert" modules by manipulating sys.modules. It keeps a list of imported modules, and there you can make your module appear under the same name as the original one. You must do this manipulating before any module that imports the module you want to fake though.
You can also make a package called a different name, but in that package actually use the original module name, for your completely different module. This works well as long as the original module isn't installed.
In none of these cases you can use both modules at the same time. For that you need to monkey-patch the original module.
And of course: It' perfectly possible to just call the new module with the old name. But it might be confusing.
Is it possible to divert a module in python? (ResourceX diverted to ResourceXSimulated)