Monte Carlo test fixtures write their logs into the working directory
維護者通常 3 天內回覆
評估
研究方向
從 tests/fixtures/monte_carlo/monte_carlo_fixtures.py 和 tests/unit/simulation/test_monte_carlo_plots_background.py 開始,issue 指出這裡傳入的是相對檔名;將其與 tests/integration/simulation/test_monte_carlo.py 中的清理作法進行比較。執行 pytest tests/unit/simulation -q 並檢查 git status --porcelain;完成的標準是測試執行後工作目錄中沒有留下產生的檔案。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
The Monte Carlo test fixtures pass a bare filename, so the logs land in whatever directory pytest was started from. Running the unit tests leaves three untracked files in the repository root, and nothing is ignoring them.
To Reproduce
On a clean develop:
$ git status --porcelain # nothing
$ pytest tests/unit/simulation -q
197 passed, 5 skipped
$ git status --porcelain
?? monte_carlo_test.errors.txt
?? monte_carlo_test.inputs.txt
?? monte_carlo_test.outputs.txt
All three are zero bytes, so they come from the files being opened rather than from anything being written.
Expected behavior
The suite leaves the working tree as it found it.
Additional context
The name comes from the shared fixture:
# tests/fixtures/monte_carlo/monte_carlo_fixtures.py
return MonteCarlo(
filename="monte_carlo_test",
...
)
That is relative, so it resolves against the current working directory. It appears in three places: twice in that fixture and once in tests/unit/simulation/test_monte_carlo_plots_background.py.
There is already a workaround for this in the tree, which is what made me look. tests/integration/simulation/test_monte_carlo.py carries a helper that removes the files by name:
def _post_test_file_cleanup():
"""Clean monte carlo files after test session if they exist."""
files_to_cleanup = [
"monte_carlo_class_example.kml",
"monte_carlo_test.errors.txt",
...
It is called from finally blocks in the integration tests, so it does not run for a unit-only invocation, which is why those runs leave the files behind. Its list also names a .kml and three .png, so more than the Monte Carlo logs are being written to the working directory.
Two ways to go, and I do not have a preference strong enough to argue for one:
- point the fixtures at
tmp_path, which removes the need for the cleanup helper as well; - or add the names to
.gitignore, which hides them without stopping them.
The first is the one that would let the helper go away. Happy to open a pull request if that is the direction, though it touches fixtures several tests share, so it seemed worth asking first.
Not urgent. It is a papercut, but an untracked file in the root is easy to sweep into an unrelated commit.
- 主要語言
- Python
- 星號
- 1.1k
- 分支
- 280
- 平均合併
- 3 天 2 小時
- 30 天內合併 PR
- 24
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
RocketPy-Team/RocketPy 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
RocketPy-Team/RocketPy#1255 ·
維護者通常 3 天內回覆
-
難度 1/5 1 小時以內 新手友好度 92/100
RocketPy-Team/RocketPy#1241 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
RocketPy-Team/RocketPy#1202 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
RocketPy-Team/RocketPy#1171 · 1 則留言 ·
維護者通常 3 天內回覆
-
難度 3/5 1-2 天 新手友好度 56/100
RocketPy-Team/RocketPy#1251 ·
維護者通常 3 天內回覆
查看 RocketPy-Team/RocketPy 的全部 Issue
相似的 Issue
-
docs(contributing): the two things that silently block a PR可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉available documentation good first issue
難度 1/5 1-3 小時 新手友好度 95/100
Nixitov/Riptide-Native#944 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 88/100
JTHCode/secretguard#24 ·
維護者通常 1 天內回覆
-
area: middleware documentation good first issue
難度 2/5 1-3 小時 新手友好度 88/100
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
good first issue
難度 1/5 1 小時以內 新手友好度 95/100
omarelshamy25x/shamy-hijri#63 ·
維護者通常 1 天內回覆