python - 运行鼻子测试会破坏腻子会话
问题描述
当我nosetests
在putty
会话中运行时,命令提示符停止工作。例如,我输入的任何键都会变成)
到目前为止,我发现恢复的唯一方法是重新启动会话。
我运行的命令是:
nosetests -v --with-xunitmp -m "(?:\b|_)[Tt]est" --xunitmp-file nosetests.xml --processes=10 --process-timeout=600
我使用nosetests1.3.7
和python3.5.1
编辑:
我已经缩小了一点。
- 它发生在 tmux 之外(在腻子会话中)
- 发生这种情况是因为我从我的 python 测试中启动了其他进程
这是一个例子:
from unittest import TestCase
from subprocess import Popen
import time
class MyTest(TestCase):
def test_this(self):
self.assertTrue(True)
def test_with_process(self):
process = Popen(['watch', 'ls'])
time.sleep(1)
if process.poll() is None:
process.kill()
编辑2:
似乎重定向子流程以/dev/null
解决问题:
from unittest import TestCase
from subprocess import Popen, DEVNULL
import time
class MyTest(TestCase):
def test_this(self):
self.assertTrue(True)
def test_with_process(self):
process = Popen(['watch', 'ls'],
stdout=DEVNULL,
stderr=DEVNULL,
stdin=DEVNULL)
time.sleep(1)
if process.poll() is not None:
print("KILLING")
process.kill()
process.communicate()
它解决了这个问题,我想了解为什么会发生这种情况......
解决方案
推荐阅读
- sql - 如何将记录类型转换为 jsonb 或使用诸如 <@ bewteen jsonb 之类的运算符并在 postgresql 中记录?
- angular - Angular无法通过数组读取未定义循环的属性
- swift - 如果文本字段中的字符串为空,如何不添加单元格?
- python - 重命名数据框中的相同标签
- angular - 创建组件并附加到 div
- scala - 如何将集合作为新列附加到具有多列的 DataFrame?
- jquery - 在 JQuery 中截断字符串
- r - 有没有办法清理 r 中的日期和时间数据?
- swift - 在 Swift 中访问具有范围的二维数组
- node.js - 适用于 Telegram、Facebook、Slack 等平台的自定义有效负载,用于 Nodejs 中的 DialogFlow