2016-11-15 66 views
0

一直在尋找這一點,並感到驚訝,沒有找到太多。我目前正在和pytest一起工作,希望改進通過測試的細節。改進pytest結束報告以顯示個別通過的測試?

這裏的目的是報告以相同的細節水平通過故障的單個測試。使用例如,從網站失敗的測試:

$ pytest 
======= test session starts ======== 
platform linux -- Python 3.5.2, pytest-3.0.4, py-1.4.31, pluggy-0.4.0 
rootdir: $REGENDOC_TMPDIR, inifile: 
collected 1 items 

test_sample.py F 

======= FAILURES ======== 
_______ test_answer ________ 

def test_answer(): 
    >  assert func(3) == 5 
    E  assert 4 == 5 
    E  + where 4 = func(3) 

test_sample.py:5: AssertionError 
======= 1 failed in 0.12 seconds ======== 

我正在尋找的經過測試的方式來報道了類似的莊園,可能與自定義文本?

如果不是將自定義文本添加到結束報表的方式就足夠了。

這是可能的還是我在這裏嘗試的東西是不正確的?

乾杯, R.

回答

0

py.test -s顯示了成功的測試stdout

這不像在上面的例子中失敗的結果,但在成功的傳遞你沒有任何斷言被解僱。

所以你會看到你的測試將成功傳遞給stdout

+0

後來我在stackoverflow上找到了相同的答案http://stackoverflow.com/questions/24617397/how-to-print-to-console-in-py-test – MasterAndrey