我试图从代码中运行pytest,如此处所述https://pytest.org/latest/usage.html#calling-pytest-from-python-code
但pytest仍在吐出输出,因为即使从控制台执行此操作也没有-q
修饰符(如下例所示)
py.test
============================= test session starts =============================
platform win32 -- Python 2.7.10, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\A2eEngineer1\Desktop, inifile:
collected 2 items
test_range.py .F
================================== FAILURES ===================================
________________________ TestGettersSetters.test_fail _________________________
self = <test_range.TestGettersSetters instance at 0x03257B48>
def test_fail(self):
> assert (self.i != 42)
E assert 42 != 42
E + where 42 = <test_range.TestGettersSetters instance at 0x03257B48>.i
test_range.py:9: AssertionError
===================== 1 failed, 1 passed in 0.05 seconds ======================
-
py.test -q
.F
================================== FAILURES ===================================
________________________ TestGettersSetters.test_fail _________________________
self = <test_range.TestGettersSetters instance at 0x0334E6C0>
def test_fail(self):
> assert (self.i != 42)
E assert 42 != 42
E + where 42 = <test_range.TestGettersSetters instance at 0x0334E6C0>.i
test_range.py:9: AssertionError
1 failed, 1 passed in 0.03 seconds
-
py.test -qqq
.F
================================== FAILURES ===================================
________________________ TestGettersSetters.test_fail _________________________
self = <test_range.TestGettersSetters instance at 0x031CE6C0>
def test_fail(self):
> assert (self.i != 42)
E assert 42 != 42
E + where 42 = <test_range.TestGettersSetters instance at 0x031CE6C0>.i
test_range.py:9: AssertionError
如输出所示,所有这些都是等于(除了第一个中的标题),但是在文档(与上面相同的链接)上,它表明pytest不应该产生输出(whit -qq
)
所以。这是预期的行为,这是一个错误还是我做错了什么?