import unittest
import sys


class TestSample(unittest.TestCase):

    def test(self):
        old_main = sys.modules['__main__']
old_main_file = sys.modules['__main__'].__file__
sys.modules['__main__'] = sys.modules['app']
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