How can I limit the maximum running time for a unit test?

后端 未结 1 1867
无人及你
无人及你 2020-12-06 08:55

I am currently running some unit tests that might either take a long time before failing or run indefinitely. In a successful test run they will always complete within a cer

相关标签:
1条回答
  • 2020-12-06 09:41

    you can install the pytest-timeout plugin and then mark your test functions with a timeout in seconds.

    @pytest.mark.timeout(300)
    def test_foo():
       pass
    

    Look at the plugin download and usage instructions at https://pypi.python.org/pypi/pytest-timeout

    0 讨论(0)
提交回复
热议问题