logo
publist
写文章

简介

该用户还未填写简介

擅长的技术栈

可提供的服务

暂无可提供的服务

Python自动化测试之使用pytest-mock模拟用户输入

【代码】Python自动化测试之使用pytest-mock模拟用户输入。

文章图片
#python#pytest#开发语言
{'detail': 'Authentication credentials were not provided.'} django rest framework

昨天手动测试 djangorestframework时,遇到 403 {'detail': 'Authentication credentials were not provided.'} 的问题,今天自动测试又遇到了,所以记录一下:一、手动提交时,我是这样解决问题的:http -a wenjie:jaket521 POST http://127.0.0.1:8000/snippets/

tortoise-orm在fastapi的lifespan中访问数据库表时报for r in self._routers:TypeError: ‘NoneType‘ object is not it

注:pip安装时如果报443连接超时,可以用ssh的方式(本地公钥需配置到github里):pip install --upgrade 'git+ssh://git@github.com/tortoise/tortoise-orm.git'解决:升级tortoise-orm使用github上的待发布版。如果还想消除warnning提示,可参照库文档的示例修改代码。升级完成后,不再报错了。

文章图片
#fastapi#python
No module named pip.main; ‘pip’ is a package and cannot be directly executed

pip --version时报了No module named pip.main的错误参考了这个:No module named pip.__main__; ‘pip‘ is a package and cannot be directly executed_天天放羊的博客-CSDN博客执行了:python -m ensurepip然后再重新python -m pip install -U pip

#pycharm#ide#python
fdfs_client.exceptions.ResponseError: Tracker response length is invaild, expect: 40, actual: 70

FastDFS的版本是最新的6.12(截至2024.05.15)升级成功后,重新执行代码,发现已经不再报错,能正常上传文件了。(需要Python3.10+)方案一:升级依赖包(

文章图片
#python#开发语言
fdfs_client.exceptions.ResponseError: Tracker response length is invaild, expect: 40, actual: 70

FastDFS的版本是最新的6.12(截至2024.05.15)升级成功后,重新执行代码,发现已经不再报错,能正常上传文件了。(需要Python3.10+)方案一:升级依赖包(

文章图片
#python#开发语言
FastAPI使用ORJSONResponse作为默认的响应类型

FastAPI默认使用Python的标准库来做json解析,如果换成rust编写的orjson,速度上会快一些。2. 设置为默认响应类型。

文章图片
#fastapi
tortoise-orm在fastapi的lifespan中访问数据库表时报for r in self._routers:TypeError: ‘NoneType‘ object is not it

注:pip安装时如果报443连接超时,可以用ssh的方式(本地公钥需配置到github里):pip install --upgrade 'git+ssh://git@github.com/tortoise/tortoise-orm.git'解决:升级tortoise-orm使用github上的待发布版。如果还想消除warnning提示,可参照库文档的示例修改代码。升级完成后,不再报错了。

文章图片
#fastapi#python
ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

解决ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

#linux#运维#服务器
poetry导出requirements.txt

命令如下:poetry export --with=dev --without-hashes -o dev_requirements.txt

文章图片
#linux#运维#服务器
    共 23 条
  • 1
  • 2
  • 3
  • 请选择