def run_cmd(app, cmd):
    """Run a command and return a tuple with (stdout, stderr, exit_code)"""
    os.environ['FLASK_APP'] = app
    process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    (stdout, stderr) = process.communicate()
    print('\n$ ' + cmd)
    print(stdout.decode('utf-8'))
    print(stderr.decode('utf-8'))
    return stdout, stderr, process.wait()
Run a command and return a tuple with (stdout, stderr, exit_code)
tests/test_custom_template.py