Monte Carlo test fixtures write their logs into the working directory

オープン 初心者向け
#1,189 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@thc1006 がすでに取り組んでいます。

2026年12月3日 から。

  • #1253 @thc1006 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
python
領域
testing

調査の方向性

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RocketPy-Team/RocketPy のほかの issue

RocketPy-Team/RocketPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。