运行鼻子测试腐蚀腻子会议

2024-04-20 12:10:26 发布

您现在位置:Python中文网/ 问答频道 /正文

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

到目前为止,我找到的唯一恢复方法是重新启动会话。你知道吗

我运行的命令是:

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

我使用nosetests1.3.7和python3.5.1

编辑:

我把范围缩小了一点。你知道吗

  • 它发生在tmux之外(在putty会话中)
  • 这是因为我从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()

它解决了问题,我想知道为什么会发生这种事。。。你知道吗


Tags: fromtestimport命令selftimedefwith