首页 > 解决方案 > 运行鼻子测试会破坏腻子会话

问题描述

当我nosetestsputty会话中运行时,命令提示符停止工作。例如,我输入的任何键都会变成)

到目前为止,我发现恢复的唯一方法是重新启动会话。

我运行的命令是:

nosetests -v --with-xunitmp -m "(?:\b|_)[Tt]est" --xunitmp-file nosetests.xml  --processes=10 --process-timeout=600

我使用nosetests1.3.7和python3.5.1

编辑:

我已经缩小了一点。

这是一个例子:

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()

它解决了这个问题,我想了解为什么会发生这种情况......

标签: pythonputtytmuxnose

解决方案


推荐阅读