Python相關環境:
1.Windows 10
2.JDK 1.8
3.Python 3.7.2
4.Pip 18.1 from c:\python37\lib\site-packages\pip (python 3.7)
5.Eclipse
安裝Pytest+allure過程:參考鏈接一:https://blog.csdn.net/liudinglong1989/article/details/83023886
1.安裝pytest
CMD下執行命令pip install pytest,安裝成功,版本號:5.2.2
2.安裝allure
根據鏈接一指導安裝
下載allure壓縮包,版本號:2.7.0
在目錄下解壓壓縮包
設置系統環境變量:指向allure的bin目錄
3.安裝pytest-allure-adaptor
CMD下執行命令pip install pytest-allure-adaptor,安裝成功,版本號:1.7.10
問題處理過程:
1.在Eclipse中寫入基礎腳本,點擊Run as Python Run
腳本如下:
2.報錯,錯誤一:執行后,發現報錯,報錯信息如下:
pluggy.manager.PluginValidationError: unknown hook 'pytest_namespace' in plugin <module 'allure.pytest_plugin' from 'C:\\Users\\wenqi\\AppData\\Roaming\\Python\\Python37\\site-packages\\allure\\pytest_plugin.py'>
網上查找錯誤信息,都提示是pytest版本太高導致,建議安裝pytest低版本4.0.2
2.1卸載pytest高版本:pip uninstall pytest
2.2安裝pytest低版本:pip install pytest==4.0.2
(安裝過程發現通過公司wif安裝不了,找不到對應的包,然后通過手機熱點安裝,可安裝成功,具體原因未知)
2.3 報錯,錯誤二:安裝完成后,查案pytest版本號,發現報錯,如下:
TypeError: attrib() got an unexpected keyword argument 'convert'
3.再次卸載pytest4.0.2,重新安裝pytest最新版本,eclipse中運行程序時仍報錯,同“錯誤一”
4.在網上繼續尋找解決方案,在鏈接二:https://www.cnblogs.com/wsy1103/p/10530397.html中有介紹到和pytest集成,需要安裝allure-pytest
繼續嘗試着安裝:pip install allure-pytest,安裝成功,版本號:2.8.6
5.在Eclipse中運行程序,仍報錯,不過此時報錯信息和“錯誤一”不同,報錯信息如下:
No module named 'allure.pytest_plugin'; 'allure' is not a package
6.在網上查詢此錯誤,在鏈接三:https://www.cnblogs.com/lansan0701/p/10345142.html中介紹,卸載pytest-allure-adaptor、再安裝allure-pytest
由於已安裝allure-pytest,故只卸載pytest-allure-adaptor
7.卸載成功后,再次在Eclipse中執行程序,發現程序運行成功
以上,為整個python+allure安裝過程,問題思考過程
以上,綠色背景的三個安裝,為正確安裝過程