![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytest
hide_in_darkness
萌新一枚
展开
-
pytest学习--参数和skip
import pytestimport sysimport requests# pytest.mark.skip 跳过用例""" pytest.mark.skip(*,reason = None ) :param reason(str)跳过测试功能的原因"""@pytest.mark.skip(reason='there is no way')def test_the_unknown(): print("这条测试用例将会被跳过") assert 1原创 2020-09-06 23:52:41 · 273 阅读 · 0 评论 -
pytest学习--fixture
import pytestimport smtplibimport contextlib# @pytest.fixture(scope='function')# def smtp_connection():# return smtplib.SMTP("smtp.gmail.com", 587, timeout=5)### '''# pytest --fixtures test_simplefactory.py# 查看可用的灯具(带前缀的灯具_仅在添加-v选项后原创 2020-09-06 23:50:13 · 161 阅读 · 0 评论 -
pytest学习--断言
import pytest"""断言"""def f(): return 3# pytest允许您使用标准python assert来验证Python测试中的期望和值def test_function(): assert f() == 4, "never see you again" # 自行断言 # 断言可以指定一条消息,assert condition, message # 消息将简单地显示在跟踪中AssertionError: message原创 2020-09-06 23:14:34 · 124 阅读 · 0 评论 -
pytest学习--基础测试
import pytest''' 安装pytest: pip install pytest 查看pytest版本: pytest --version pytest参数帮助: pytest -h | --help pytest遵循其Python测试发现约定来发现所有测试 因此它会找到两个带test_前缀的函数 且无需继承任何子类'''# import pdb# '''# pytest允许您在每次测试开始时通过命令行选项立即进入PDB提示符:原创 2020-09-06 22:54:51 · 122 阅读 · 0 评论