pytest常用插件


测试文件:
from time import sleep
import pytest
def test_rerun1():
sleep(0.5)
assert 1 == 2
def test_rerun2():
sleep(0.5)
assert 2 == 2
@pytest.mark.flaky(reruns=5, reruns_delay=2)
def test_rerun3():
sleep(0.5)
assert 3 == 2


pip install pytest-rerunfailures
pytest test_rerun.py --reruns 3
pytest test_rerun.py --reruns 3 --reruns-delay 1
2.

测试代码:
import pytest
def test_a():
# assert 1 == 2
# assert False == True
# assert 100 == 200
pytest.assume(1 == 1)
pytest.assume(False == True)
pytest.assume(100 == 200)
pytest.assume(3 == 1)

测试代码:
from time import sleep
import pytest
@pytest.mark.run(order=2)
def test_1():
sleep(1)
assert True
#@pytest.mark.third
def test_2():
sleep(1)
assert True
@pytest.mark.run(order=1)
def test_3():
sleep(1)
assert True



pytest test_ordering.py -n 3
-n后面加上并发的数量即用例数

浙公网安备 33010602011771号