sys.modules['__main__'].__file__ = sys.modules['app'].__file__
sys.modules['__main__'] = old_main
sys.modules['__main__'].__file__ = old_main_file
How to unit-test code that uses python-multiprocessing