全然わからない pytestをコマンドとしてではなくモジュールとして呼んで使ってたので同じことを指定してみたが詳細不明なエラーになる .vscode/settings.json
{
"python.pythonPath": "venv/bin/python",
"python.testing.pytestPath": "venv/bin/python -m pytest", // here
"python.testing.pytestArgs": [
"tests", "--cov=server", "--cov-report=xml"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true
}
では、ということでこんなシェルスクリプトを挟んでみたがこれもよくわからない結果 bash
#!/bin/bash
python -m pytest $* --cov=server --cov-report=xml
python - Imports break VSCode testing with pytest - Stack Overflow ここにワークアラウンドがある tests/ini.py
import sys
sys.path.insert(0, ".")
というわけでGUIでテストできるようになった。
これ、便利なのかなぁ?? 一部のテストだけ実行すると、当然それでカバーされてないところはカバレッジ的には「テストで通らない」ということになってしまう。 カバレッジを出力するためのテストをシェルスクリプトに括り出して、VSCodeからテストを走らせるときにはカバレッジ出力をしない方が良いかも。