代码之家  ›  专栏  ›  技术社区  ›  0x26res

运行nosetest会损坏tmux面板

  •  1
  • 0x26res  · 技术社区  · 6 年前

    当我跑的时候 nosetests 在我的 putty 会话时,命令提示停止工作。例如,我键入的任何键变成什么 )

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

    我运行的命令是:

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

    我用鼻子检查 1.3.7 还有蟒蛇 3.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()
    

    似乎将子流程重定向到 /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()
    

    它解决了这个问题,我想知道为什么会这样。。。

    0 回复  |  直到 6 年前