簡體   English   中英

如何在 py.test 中重復測試模塊?

[英]How can I repeat a test module in py.test?

我想重復一個測試模塊 N 次。
順序非常重要。

test_stress.py 的內容

import pytest
@pytest.mark.usefixtures("class_setup_teardown")
class TestStressRobot:
    def test_1(self):
        print "\nstressing part 1..."
        assert True

    def test_2(self):
        print "\nstressing part 2..."
        assert True

    def test_3(self):
        print "\nstressing part 3..."
        assert True

當我運行py.test --repeat=2 時,輸出是:

test_stress.pyTestStressRobot.test_1[0] ✓
test_stress.pyTestStressRobot.test_1[1] ✓
test_stress.pyTestStressRobot.test_2[0] ✓
test_stress.pyTestStressRobot.test_2[1] ✓
test_stress.pyTestStressRobot.test_3[0] ✓
test_stress.pyTestStressRobot.test_3[1] ✓

我不希望它在每個測試中重復,而是每個測試模塊重復。

有可能有這樣的東西嗎?

test_stress.pyTestStressRobot.test_1[0] ✓
test_stress.pyTestStressRobot.test_2[0] ✓
test_stress.pyTestStressRobot.test_3[0] ✓
test_stress.pyTestStressRobot.test_1[1] ✓
test_stress.pyTestStressRobot.test_2[1] ✓
test_stress.pyTestStressRobot.test_3[1] ✓

嘗試

pytestmark = [pytest.mark.usefixtures('module_scoped_fun')]

在模塊級別使用模塊范圍的參數化夾具?

嘗試這個:

pytest --flake-finder --flake-runs=runs

https://github.com/dropbox/pytest-flakefinder

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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