记录学习pytest自动化框架遇到的问题及解决方案

问题1:ImportError: cannot import name 'url_quote' from 'werkzeug.urls'
答:

其根本原因是Werkzeug 3.0.0删除了之前已弃用的代码: https: //werkzeug.palletsprojects.com/en/3.0.x/changes/#version-3-0-0

请更新您的 Flask 版本,Flask 2.2.2不受支持:https ://github.com/pallets/flask/releases

无论如何,如果你坚持使用已弃用的版本Flask,或者如果你的代码直接使用url_quote,那么你可以切换到内置版本,你需要自己固定 Werkzeug urllib

问题2:

问题3:打开项目的位置错了,应该从pythonproject打开,而不是上一层目录打开

问题4:安装库有时候不成功,可以确认下是不是库的版本与python版本不兼容

问题5、pip3 install --upgrade urllib3 这个库与你的python版本不兼容

问题6.E   DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).

from datetime import datetime, timezone

def aware_utcnow():
    return datetime.now(timezone.utc)

def aware_utcfromtimestamp(timestamp):
    return datetime.fromtimestamp(timestamp, timezone.utc)

def naive_utcnow():
    return aware_utcnow().replace(tzinfo=None)

def naive_utcfromtimestamp(timestamp):
    return aware_utcfromtimestamp(timestamp).replace(tzinfo=None)

print(aware_utcnow())
print(aware_utcfromtimestamp(0))
print(naive_utcnow())
print(naive_utcfromtimestamp(0))
  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值