在使用 subprocess 执行测试时,如下所示:
subprocess.Popen(["./manage.py", "test", "-x", "--settings=settings_test"], stdout=subprocess.PIPE, stdin=subprocess.PIPE).communicate()
仅捕获测试输出的初始部分。所以我得到了返回的元组
("\x1b[32mUsing database: develop\x1b[0m\n\x1b[33mRunning tests against sqlite3 in memory database\x1b[0m\nnosetests --verbosity 1 -x\nCreating test database for alias 'default'...\nDestroying test database for alias 'default'...\n", None)
然而,这错过了关键的最后三行
Ran 260 tests in 70.131s
OK (SKIP=1)
有没有办法使用子进程捕获这个输出?