def run_script(file_path):
    process = subprocess.Popen(['myscript', -M, file_path], stdout=
        subprocess.PIPE)
output, err = process.communicate()
return process.returncode
Mocking a subprocess call in Python