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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…