2012-06-19 24 views
2

我有一個py.test測試功能標記爲xfail:在py.test中,當我顯式跳過標記爲xfail的測試時,如何才能將其報告爲「跳過」而不是「xfailed」?

@pytest.mark.xfail 
def test_that_fails(): 
    assert 1 == 2 

在我pytest_runtest_setup()掛鉤,我明確地跳過這個測試:

def pytest_runtest_setup (item): 
    pytest.skip ('Skipping this test') 

當我運行py.test,它會報告測試xfailed:

tests.py x 

========================== 1 xfailed in 1.69 seconds =========================== 

我該如何讓py.test報告這個測試被跳過?

看起來我在問:「我的pytest_runtest_setup()鉤子中如何刪除xfail標記形式的測試?」

謝謝。

回答

1

感謝bug報告:)

我同意期待py.test報告這是一個「跳過」了測試,而不是xfail是有道理的。畢竟,如果跳過測試,xfail-outcome(xfail/xpass)無法確定。我只是修復了這個問題,你可以通過鍵入安裝:

pip_install -i http://pypi.testrun.org -U pytest 
# using easy_install is fine as well 

這應該讓你2.2.5.dev4與「py.test --version」和解決您的問題。它將成爲下一個pypi版本的一部分。