今天寫代碼犯了一個不應該犯的小錯誤,通過記錄下來便於查看
1、報錯代碼如下:
1 platform win32 -- Python 3.7.3, pytest-4.0.2, py-1.8.0, pluggy-0.12.0 2 rootdir: D:\work\project\freshAif2\testcase\testmodule, inifile: 3 plugins: allure-adaptor-1.7.10, forked-1.0.2, html-1.20.0, metadata-1.8.0, xdist-1.29.0collected 0 items 4 5 ======================== no tests ran in 0.18 seconds ========================= 6 7 Process finished with exit code 0 8 9 Empty suite
2、查看原因
查看項目文件 發現以test_為命名
運行代碼如下
3、解決
由於pychar中以pytest運行,它會默認把test、test_開頭的.py文件當做單元測試,而我的代碼又不是單元測試格式,只是做一個平時的測試,所以需要修改文件名
修改文件test_interview.py 為interview.py ,再次運行,成功了,結果如下: