因为不想以后遇到同样的困境束手无策,所以想要留下些什么
于是就有了下文
铛铛铛铛……
首先,第一次用pytest,装环境,我看到别人python3.7用pytest5.多的版本没有任何问题,而我就不一样了,刚开始我想装最新版本5.3.5,下载时报错相关包没有下载成功,而后下载5.3.1,成功了,但是运行后
报错:‘TestCaseFunction’ object has no attribute ‘get_marker’
报错原因:版本不对应,pytest版本高了些
解决方法:下载3.8.2版本pytest成功啦(一些试错:下载成功但运行报错的版本:5.3.1,4.5.0;下载出错版本:3.8.0,3.8.1,4.0.2,4.1.1,4.6.2等,其他版本不是不可以,只是我没有尝试,如果不嫌麻烦可以试试,哈哈,我已经不想尝试了)
ps:
一.默认是unittest框架,需要改成pytest框架,方式:在搜索栏搜索pytest,点击Toools,将“unittest”改为“pytest”,如图1
二.想用命令pip install pytest==4.1.1安装
报错:You are using pip version 10.0.1, however version 20.0.2 is available. You should consider upgrading,如图2.
解决方法:1.conda install pip
2.python -m pip install --upgrade pip
如果不成功听说第一步可以操作三次或许有效哦