簡體   English   中英

如何刪除跳過測試的詳細輸出?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM