代码之家  ›  专栏  ›  技术社区  ›  guettli

没有输出,即使使用'py。测试-s`

  •  0
  • guettli  · 技术社区  · 6 年前

    我想用 py.test 与…结合 hunter :

    PYTHONHUNTER="module_startswith='foo'" py.test -s -k test_bar
    

    不幸的是,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版本,但没有插件)。

    原因可能是什么?

    如何调试这个?

    0 回复  |  直到 6 年前
        1
  •  8
  •   guettli    6 年前

    我找到了一份工作。

    如果我读这两行,那么 -s 选项(快捷方式为--capture=no) py.test 作品

        def test_when_the_moon_is_in_the_seventh_house(self):
    +        import hunter
    +        hunter.trace(module_startswith='modlink')
            ...
    

    我将观看比赛,我很高兴。

    不修改源代码的解决方案就好了。

        2
  •  0
  •   Max Voitko    6 年前
    1. 使用相应的pytest选项进行调试:

      pytest -v --tb=long

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

    例子: How to debug in PyCharm .

    推荐文章