Pytest常用插件pytest-timeout:Put Time Limits on Your Tests
作者:互联网
pytest-timeout:Put Time Limits on Your Tests
[https://pypi.python.org/pypi/pytest-time]
运行命令pip install pytest-timeout,安装插件
E:\Programs\Python\Python_Pytest\TestScripts>pip install pytest-timeout
Collecting pytest-timeout
Downloading https://files.pythonhosted.org/packages/58/92/f60ea2e27074d6f97c8aaf21e34d1f838eb623e4b8070680846c65318a10/pytest_timeout-1.3.3-py2.py3-none-any.whl
Requirement already satisfied: pytest>=3.6.0 in c:\python37\lib\site-packages (from pytest-timeout) (4.5.0)
Requirement already satisfied: attrs>=17.4.0 in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (19.1.0)
Requirement already satisfied: atomicwrites>=1.0 in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (1.3.0)
Requirement already satisfied: six>=1.10.0 in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (1.12.0)
Requirement already satisfied: py>=1.5.0 in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (1.8.0)
Requirement already satisfied: more-itertools>=4.0.0; python_version > "2.7" in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (7.0.0)
Requirement already satisfied: colorama; sys_platform == "win32" in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (0.4.1)
Requirement already satisfied: wcwidth in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (0.1.7)
Requirement already satisfied: pluggy!=0.10,<1.0,>=0.9 in c:\python37\lib\site-packages (from pytest>=3.6.0->pytest-timeout) (0.11.0)
Requirement already satisfied: setuptools in c:\users\davieyang\appdata\roaming\python\python37\site-packages (from pytest>=3.6.0->pytest-timeout) (41.0.1)
Installing collected packages: pytest-timeout
Successfully installed pytest-timeout-1.3.3
执行命令pytest --timeout=0.1
E:\Programs\Python\Python_Pytest\TestScripts>pytest --timeout=0.1
================================ test session starts ===============================================
platform win32 -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, repeat-0.8.0, forked-1.0.2, allure-pytest-2.6.3
timeout: 0.1s
timeout method: thread
timeout func_only: False
collected 17 items
test_asserts.py ...F..F [ 41%]
test_fixture1.py .. [ 52%]
test_fixture2.py .. [ 64%]
test_one.py .F [ 76%]
test_two.py .... [100%]
================================== FAILURES ===============================================
________________________________________ test_add4 ______________________________________________
def test_add4():
> assert add(17,22) >= 50
E assert 39 >= 50
E + where 39 = add(17, 22)
test_asserts.py:34: AssertionError
____________________________________________ test_true ______________________________________________
def test_true():
> assert not is_prime(7)
E assert not True
E + where True = is_prime(7)
test_asserts.py:65: AssertionError
__________________________________________ test_not_equal _________________________________________
def test_not_equal():
> assert (1, 2, 3) == (3, 2, 1)
E assert (1, 2, 3) == (3, 2, 1)
E At index 0 diff: 1 != 3
E Use -v to get the full diff
test_one.py:9: AssertionError
======================== 3 failed, 14 passed, 1 warnings in 0.32 seconds =======================================
标签:插件,Limits,satisfied,3.6,pytest,timeout,Time,test,packages 来源: https://blog.csdn.net/dawei_yang000000/article/details/95087937