From aa0d4835b17a467ac36310f309cbd4c7570a126f Mon Sep 17 00:00:00 2001 From: Norio Tamaru Date: Mon, 25 May 2026 11:58:40 +0900 Subject: [PATCH] Fix pytest temp directory handling --- AGENTS.md | 7 +++++++ prompts/codex_task_template.md | 6 ++++++ pytest.ini | 7 +++++++ scripts/dev_check.ps1 | 4 ++-- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 pytest.ini diff --git a/AGENTS.md b/AGENTS.md index 1e996b7..ca43c70 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -84,6 +84,13 @@ README、docs、tests、src のいずれを変更する場合も、この確認 - Codex環境で `py -m pytest` が実行できない場合は、以下の順で実行を試す。 1. `python -m pytest` 2. `where.exe python` で確認した Python 実行ファイルのフルパスを使った pytest 実行 + 3. Codex同梱Pythonの有無を確認し、存在する場合はそれを使った pytest 実行 +- Codex環境では、OSの `py` / `python` がPATHに存在しない場合がある。 +- Codex同梱Pythonの例: + `C:\Users\tamaru\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe` +- Codex同梱Pythonを使うpytest実行例: + `& 'C:\Users\tamaru\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' -m pytest tests -p no:cacheprovider --basetemp "$env:TEMP\utr_lan_pytest_tmp"` +- `logs/real_device/` は実機ログ保存用であり、pytest一時領域には使わない。 - それでも実行できない場合は、理由と実行できなかったコマンドを明記する。 - ユーザー環境でpytest成功が確認済みの場合は、「ユーザー環境ではpytest成功確認済み」と分けて記載する。 - Codex自身が実行していないpytest結果を、自分の確認結果として書かない。 diff --git a/prompts/codex_task_template.md b/prompts/codex_task_template.md index 1e12da6..c6f264a 100644 --- a/prompts/codex_task_template.md +++ b/prompts/codex_task_template.md @@ -18,6 +18,12 @@ - `real_device_check.py` は実行しない。 - `git commit`、`git push`、PR mergeは禁止。 - pytest未実行を成功扱いしない。 +- `py` / `python` がPATHに存在しない場合は、Codex同梱Pythonの有無を確認してpytestを実行する。 +- Codex同梱Pythonの例: `C:\Users\tamaru\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe` +- pytest実行例: `& 'C:\Users\tamaru\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' -m pytest tests -p no:cacheprovider --basetemp "$env:TEMP\utr_lan_pytest_tmp"` +- pytestが実際に起動して完了した場合のみ「pytest成功」または「pytest失敗」と報告する。 +- それでも実行できない場合のみ「pytest未実行」とし、試したコマンドと失敗理由を明記する。 +- `logs/real_device/` は実機ログ保存用であり、pytest一時領域には使わない。 - 不明な通信仕様は推測で実装しない。 - 通信仕様に関わる変更が必要な場合は、根拠となる資料と確認事項を先に提示する。 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..29226fe --- /dev/null +++ b/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +testpaths = tests +norecursedirs = + .git + .pytest_cache + __pycache__ + logs diff --git a/scripts/dev_check.ps1 b/scripts/dev_check.ps1 index 286fba1..f4bd662 100644 --- a/scripts/dev_check.ps1 +++ b/scripts/dev_check.ps1 @@ -35,8 +35,8 @@ try { git status --short } - Invoke-Check "py -m pytest" { - py -m pytest + Invoke-Check "py -m pytest tests" { + py -m pytest tests } $scanScript = Join-Path $PSScriptRoot ("sec" + "ret_scan.ps1")