摘要:
报错 Forbidden (CSRF cookie not set.): 解决办法 将settings.py里面的# 'django.middleware.csrf.CsrfViewMiddleware'注释掉即可 MIDDLEWARE = [ 'django.middleware.security 阅读全文
摘要:
安装 pip install pytest-ordering 使用 import pytest @pytest.mark.run(order=2) def test_foo(): assert True @pytest.mark.run(order=1) def test_bar(): assert 阅读全文
摘要:
初始化钩子 ###pytest_addoption 调用插件和conftest.py文件的初始化挂钩,添加命令行选项 import pytest def pytest_addoption(parser:pytest.Parser): parser.addoption("--xxxx",default 阅读全文
摘要:
pytest.ini官网配置选项 注册标记标签 请注意,:标记名称之后的所有内容都是可选描述。 [pytest] markers = slow: marks tests as slow (deselect with '-m "not slow"') serial addopts 强制校验标签 没有注 阅读全文
摘要:
介绍 pytest.mark.skipif可以根据条件判断是否执行该用例, 第一个参数传入条件 可以传入True/False如果条件应该被跳过或条件字符串 第二个参数是说明/原因 reason="2大于1" 有条件的跳过用例 import pytest @pytest.mark.skipif(1<2 阅读全文
摘要:
介绍 您可以标记无法在某些平台上运行或您预计会失败的测试功能,以便 pytest 可以相应地处理它们并提供测试会话的摘要,同时保持测试套件绿色。 跳过意味着您希望测试仅在满足某些条件时才能通过,否则 pytest 应该完全跳过运行测试。常见的例子是跳过非 Windows 平台上的纯 Windows 阅读全文
摘要:
异常 Error in NonGUIDriver java.lang.IllegalArgumentException: Report generation requires csv output format, check 'jmeter.save.saveservice.output_forma 阅读全文
摘要:
介绍 parametrize装饰器可以对函数进行参数化,像用例相同场景不同数据的时候就可以使用它 函数参数化 import pytest @pytest.mark.parametrize("nub1,nub2,nub3",[[1,2,3],[2,2,4],[3,2,5]]) def test_01( 阅读全文
摘要:
读取并返回到目前为止捕获的输出,重置内部缓冲区。 返回 将捕获的内容作为具有out和err 字符串属性的命名元组。 def test_output(capsys): print("hello") captured = capsys.readouterr() assert captured.out = 阅读全文
摘要:
cache fixture 也可以根据 request fixture关联出来 例如:request.config.cache.makedir 获取给定的name缓存路径,没有该目录就会创建, @pytest.fixture def mydata(cache): val = cache.makedi 阅读全文