01 2022 档案
摘要:终端运行: pytest -v test_desktop.py --alluredir reults 非终端运行: 在app_main.py中运行,然后在pycharm右击运行 if __name__ == '__main__': pytest.main(["test_desktop.py", '-
阅读全文
摘要:安装jenkins插件 登录jenkins服务器进入插件管理安装:Allure Jenkins Plugin 创建item 构建后操作path选择 你执行allure server 指定的目录 比如:sudo allure serve reults/ 查看allure报告:
阅读全文
摘要:依赖安装: # 安装allure-pytest pip3 install allure-pytest --index-url https://pypi.douban.com/simple # 请先卸载掉 pytest-allure-adaptor # 安装allure启动一个服务来读取报告 http
阅读全文
摘要:依赖安装 # 安装pytest-html插件 pip3 install pytest-html # 执行命令生成报告 pytest --html=report.html # 指定到对应的文件夹中 pytest --html=report/report.html # 这里不要加 . 运行测试 test
阅读全文
摘要:创建两个test_XX.py文件分别测试桌面和服务器 test_desktop.py import pytest @pytest.mark.Desktop_Professional @pytest.mark.特性1 def test_1(): print('执行了桌面专业版特性1用例') asser
阅读全文
摘要:import pytest @pytest.mark.Desktop_Professional @pytest.mark.特性1 def test_1(): print('执行了桌面专业版特性1用例') assert True @pytest.mark.Desktop_Professional @p
阅读全文
摘要:安装虚拟化核心组件 安装方法 前提条件 已经配置yum源。配置方式请参见 安装操作需要root用户权限。 安装步骤 安装QEMU组件。 # yum install -y qemu 安装libvirt组件。 # yum install -y libvirt 启动libvirtd服务。 # system
阅读全文
摘要:可以声明多个请求体参数,例如 item 和 user: from typing import Optional from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseMode
阅读全文
摘要:与使用 Query 为查询参数声明更多的校验和元数据的方式相同,你也可以使用 Path 为路径参数声明相同类型的校验和元数据。 from typing import Optional from fastapi import FastAPI, Path, Query app = FastAPI() @
阅读全文
摘要:额外的校验¶ 我们打算添加约束条件:即使 q 是可选的,但只要提供了该参数,则该参数值不能超过50个字符的长度。 导入 Query¶ 为此,首先从 fastapi 导入 Query: from typing import Optional from fastapi import FastAPI, Q
阅读全文
摘要:当你需要将数据从客户端(例如浏览器)发送给 API 时,你将其作为「请求体」发送。 请求体是客户端发送给 API 的数据。响应体是 API 发送给客户端的数据。 你不能使用 GET 操作(HTTP 方法)发送请求体。 要发送数据,你必须使用下列方法之一:POST(较常见)、PUT、DELETE 或
阅读全文
摘要:不属于路径参数时,它们将被自动解释为"查询字符串"参数 from fastapi import FastAPI app = FastAPI() fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Ba
阅读全文
摘要:关于 async 我们先阅读一下廖老师的异步IO https://www.liaoxuefeng.com/wiki/1016959663602400/1017968846697824 路径参数 from fastapi import FastAPI app = FastAPI() @app.get(
阅读全文
摘要:pydantic enforces type hints at runtime, and provides user friendly errors when data is invalid. Define how data should be in pure, canonical python;
阅读全文
摘要:from typing import Optional from fastapi import FastAPI from pydantic import BaseModel # 用来声明请求体的库:1.提供运行时类型信息;2.返回友好错误提示 app = FastAPI() class Item(B
阅读全文
摘要:This module provides runtime support for type hints。 下面的函数接收与返回的都是字符串,注解方式如下: def greeting(name: str) -> str: return name greeting 函数中,参数 name 的类型是 st
阅读全文
摘要:创建一个main.py文件 查看代码 from typing import Optional from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @a
阅读全文
摘要:最近在使用Fastapi编写web接口,涉及mysql数据库了记录一下使用SQLAlcheme: https://www.osgeo.cn/sqlalchemy/orm/tutorial.htmlfrom sqlalchemy import create_enginefrom sqlalchemy.
阅读全文
摘要:try: a = 10/0 #这里会报错,try会异常退出,然后走到 except捕获异常 print(a) #不会执行的 except BaseException as e: print(e) else: print('只有try正常执行了才会执行else') #try异常后,else不会执行 f
阅读全文