为什么pytest显示跳过测试的错误通知?

时间:2016-05-18 15:15:38

标签: pytest

我通过pytest运行以下测试文件:

import pytest
@pytest.mark.skip(reason="no way of currently testing this")
def test_1():
    pass

并获得以下输出:

/PROJECTS/Pytest_example/env/bin/python2.7 /usr/local/pycharm-5.0.3/helpers/pycharm/pytestrunner.py -p pytest_teamcity /PROJECTS/Pytest_example/test_example.py
Testing started at 17:57 ...
============================= test session starts ==============================
platform linux2 -- Python 2.7.10, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /PROJECTS/Pytest_example, inifile: 
collected 1 items

../../PROJECTS/Pytest_example/test_example.py s
Test ignored.

========================== 1 skipped in 0.01 seconds ===========================

Process finished with exit code 0

为什么我没有收到通知

"no way of currently testing this"?

如何在输出中获取此通知?

1 个答案:

答案 0 :(得分:1)

这看起来像是来自其他东西的输出(因为你没有直接运行pytest),而不是来自pytest。您可以使用-rs告诉pytest显示跳过原因:

$ py.test test_example.py -rs
====================== test session starts ======================
platform linux -- Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /home/florian/tmp/so, inifile: 
plugins: mock-0.11.0
collected 1 items 

test_example.py s
==================== short test summary info ====================
SKIP [1] test_example.py:1: no way of currently testing this

=================== 1 skipped in 0.00 seconds ===================