unittest报错问题

unittest报错
想问一下大家这是哪里错了?
我看视频博主跟我一样为什么我的就不能运行

img

C:\Users\Sherl-W\anaconda3\envs\pythonProject\python.exe "C:/Program Files/JetBrains/PyCharm Community Edition 2021.1.3/plugins/python-ce/helpers/pycharm/_jb_unittest_runner.py" --target demo2 
Testing started at 23:49 ...
Launching unittests with arguments python -m unittest demo2 in C:\Users\Sherl-W\PycharmProjects\pythonProject


进程已结束,退出代码0
C:\Users\Sherl-W\anaconda3\envs\pythonProject\lib\site-packages\selenium\webdriver\remote\remote_connection.py:418: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  if resp.getheader('Content-Type') is not None:
C:\Users\Sherl-W\anaconda3\envs\pythonProject\lib\site-packages\selenium\webdriver\remote\remote_connection.py:419: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  content_type = resp.getheader('Content-Type').split(';')

以下答案引用自GPT-3大模型,请合理使用:

如何修改
这是由于selenium中,底层使用urllib3在处理http请求,相关的相应头操作已被移除,所以报出以上warning。
可以在报错的文件(remote_connection.py)的相关行内,把getheader()替换为headers.get()即可。
如把:
if resp.getheader('Content-Type') is not None:
替换为:
if resp.headers.get('Content-Type') is not None:

同理,
content_type = resp.getheader('Content-Type').split(';')
替换为:
content_type = resp.headers.get('Content-Type', '').split(';')

如果我的回答解决了您的问题,请采纳我的回答

程序没有报错,正常退出了。退出代码非0的话才表示有问题,红色的位置只是警告而已,提示一下某些方法已经废弃了。所以请详细描述下你的问题是什么?或者你期待的结果是什么?

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^