亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

pytest中導入文件不匹配

pytest中導入文件不匹配

神不在的星期二 2021-09-25 16:17:17
我在包中有一個文件名中帶有“test”,當我運行 pytest 時出現錯誤import file mismatch:imported module 'my_project.my_file_test' has this __file__ attribute:  /my_project/src/my_project/build/lib/python2.7/site-packages/foo/my_file_test.pywhich is not the same as the test file we want to collect:  /my_project/src/my_project/build/private/python2.7/lib/foo/my_file_test.pyHINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules如果我從文件中刪除“測試”,它可以正常工作,但不幸的是我無法更改它。所以問題是如何告訴pytest忽略這個文件?
查看完整描述

3 回答

?
慕萊塢森

TA貢獻1810條經驗 獲得超4個贊

所以最后很容易,我只需要在pytest.ini文件中添加測試文件模式

python_files = test_*.py

所以 pytest 停止尋找test名稱末尾的文件,默認情況下它所做的。


查看完整回答
反對 回復 2021-09-25
  • 3 回答
  • 0 關注
  • 713 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號