[英]How to remove verbose output for skipped tests?
背景:我有一堆測試(20+),我無法在我的工作機器上執行,因為它們需要一個有效的 CUDA 環境。 所以為了避免錯誤,我通過unittest.skipIf
使它們成為條件。
抽象掉細節,我的測試模塊如下所示:
@unittest.skipIf(os.environ.get('TEST_FANCY') != 'yes', "For fancy tests, set TEST_FANCY='yes'")
class FancyTests(unittest.TestCase):
def test_a(self):
self.assertEqual(1+1, 2)
def test_b(self):
self.assertEqual(1+2, 3)
現在,當我通過green
運行測試時,每個跳過的測試都會以詳細的方式報告,極大地污染了輸出,例如:
..ss.
Skipped test.test_fancy.FancyTests.test_a - For fancy tests, set TEST_FANCY='yes'
Skipped test.test_fancy.FancyTests.test_b - For fancy tests, set TEST_FANCY='yes'
Ran 5 tests in 0.355s using 4 processes
OK (passes=3, skips=2)
我希望輸出只是總結結果,類似於默認情況下標准 unittest runner 所做的,即:
..ss.
Ran 5 tests in 0.355s using 4 processes
OK (passes=3, skips=2)
雖然green
默認報告單個跳過的測試,但它允許通過-k
抑制這些測試。 從 文檔:
-k, --no-skip-report Don't print the report of skipped tests after testing
is done. Skips will still show up in the progress
report and summary count.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.