Monte Carlo test fixtures write their logs into the working directory

Ouverte Adaptée aux débutants
#1,189 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

@thc1006 y travaille déjà.

Depuis le 3/12/2026.

  • #1253 par @thc1006 — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
72/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Calme
Stack technique
python
Domaine
testing

Piste de recherche

Commencez par tests/fixtures/monte_carlo/monte_carlo_fixtures.py et tests/unit/simulation/test_monte_carlo_plots_background.py, où l’issue indique que des noms de fichiers relatifs sont transmis ; comparez avec le nettoyage dans tests/integration/simulation/test_monte_carlo.py. Exécutez pytest tests/unit/simulation -q et vérifiez git status --porcelain ; le travail est terminé si l’exécution des tests ne laisse aucun fichier généré dans le répertoire de travail.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
1.1k
Forks
280
Merge moyen
3 j 2 h
PR mergées (30 j)
24

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de RocketPy-Team/RocketPy

Toutes les issues de RocketPy-Team/RocketPy

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.