Python 没有输出,即使使用'py.test-s`

Python 没有输出,即使使用'py.test-s`,python,python-2.7,pytest,xdist,python-hunter,Python,Python 2.7,Pytest,Xdist,Python Hunter,我想结合使用py.test: 不幸的是,hunter的输出(跟踪)不可见 版本: foo_cok_d@aptguettler:~$ py.test --version This is pytest version 3.4.2, imported from /home/foo_cok_d/local/lib/python2.7/site-packages/pytest.pyc setuptools registered plugins: pytest-xdist-1.22.2 at /hom

我想结合使用
py.test

不幸的是,hunter的输出(跟踪)不可见

版本:

foo_cok_d@aptguettler:~$ py.test --version

This is pytest version 3.4.2, imported from /home/foo_cok_d/local/lib/python2.7/site-packages/pytest.pyc
setuptools registered plugins:
  pytest-xdist-1.22.2 at /home/foo_cok_d/local/lib/python2.7/site-packages/xdist/looponfail.py
  pytest-xdist-1.22.2 at /home/foo_cok_d/local/lib/python2.7/site-packages/xdist/plugin.py
  pytest-forked-0.2 at /home/foo_cok_d/local/lib/python2.7/site-packages/pytest_forked/__init__.pyc
在一个更简单(更小)的virtualenv中,它可以工作(相同的pytest版本,但没有插件)

原因可能是什么

如何调试这个?

我找到了一个解决方法

如果我选择了这两行,那么
py.test
-s
选项(快捷方式--capture=no)就起作用了

    def test_when_the_moon_is_in_the_seventh_house(self):
+        import hunter
+        hunter.trace(module_startswith='modlink')
        ...
我将观看比赛,我很高兴

不修改源代码的解决方案会更好

  • 使用相应的pytest选项进行调试:

    pytest-v--tb=long

  • 在IDE中使用断点以调试模式运行程序


  • 示例:。

    文档似乎说明您需要执行
    PYTHONHUNTER=“Q(module_startswith='foo')”
    。你试过了吗?另外,这是完整的跟踪吗?@dan klasson
    PYTHONHUNTER=“module_startswith='foo'”
    是有效的语法。它适用于命令行脚本。但不是为了pytest。你说的“那是完整的追踪”是什么意思。这看起来非常特定于库。我会把它作为一个问题发布在他们的网站上github@dan-克拉森:没有任何痕迹。只是一个冗长的
    --版本
    输出。适合我,无法复制。
        def test_when_the_moon_is_in_the_seventh_house(self):
    +        import hunter
    +        hunter.trace(module_startswith='modlink')
            ...