Monte Carlo test fixtures write their logs into the working directory
Maintainer antworten meist innerhalb von 3 Tagen
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 72/100
Rechercherichtung
Beginne mit tests/fixtures/monte_carlo/monte_carlo_fixtures.py und tests/unit/simulation/test_monte_carlo_plots_background.py, wo laut Issue relative Dateinamen übergeben werden; vergleiche dies mit der Bereinigung in tests/integration/simulation/test_monte_carlo.py. Führe pytest tests/unit/simulation -q aus und prüfe git status --porcelain; fertig ist es, wenn der Testlauf keine generierten Dateien im Arbeitsverzeichnis hinterlässt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 1.1k
- Forks
- 280
- Ø Merge
- 3 T. 2 Std.
- Gemergte PRs (30 T.)
- 24
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RocketPy-Team/RocketPy
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
RocketPy-Team/RocketPy#1255 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
RocketPy-Team/RocketPy#1241 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
RocketPy-Team/RocketPy#1202 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
RocketPy-Team/RocketPy#1171 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 56/100
RocketPy-Team/RocketPy#1251 ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in RocketPy-Team/RocketPy
Ähnliche Issues
-
docs(contributing): the two things that silently block a PREvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenavailable documentation good first issue
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 95/100
Nixitov/Riptide-Native#944 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
JTHCode/secretguard#24 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: middleware documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainer antworten meist innerhalb von 1 Tag