How can I repeat each test multiple times in a py.test run?

前端 未结 6 667
别那么骄傲
别那么骄傲 2020-12-09 02:13

I want to run each selected py.test item an arbitrary number of times, sequentially.
I don\'t see any standard py.test mechanism for doing this.

I attempted to d

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 02:28

    One possible strategy is parameterizing the test in question, but not explicitly using the parameter.

    For example:

    @pytest.mark.parametrize('execution_number', range(5))
    def run_multiple_times(execution_number):
        assert True
    

    The above test should run five times.

    Check out the parametrization documentation: https://pytest.org/latest/parametrize.html

提交回复
热议问题