1import subprocess 2sp = subprocess.Popen(['cargo', 'run', '--example', 'hello'], stdout=subprocess.PIPE) 3stdout = sp.communicate()[0].decode("utf-8") 4lines = stdout.splitlines() 5assert lines == ["life before main", "main"], "got %s" % lines 6print("Test Passed") 7