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時間
- マージ済み PR(30日)
- 24
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン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 日以内に返信