Stop doctests polluting current dir with temporary files
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start by reading the run-doctests tool and the doctests that create temporary netCDF files in the current directory; the issue does not name specific files or tests. Compare the proposed temporary-working-directory approach with a shared temporary-directory utility, keeping local-code imports and cleanup behavior in mind. Done means doctests no longer leave temporary netCDF files in the project directory without disrupting their execution.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
At present, when you run any doctests temporary netCDF files are created in the current directory.
This is slightly tiresome, and could be avoided by dumping files to a temporary directory, like pytest does.
Unfortunately, adding specific code to do that in every module / docs-sourcefile could also be tiresome and intrusive.
in run-doctests
Possibly, a way to control this could be added to the run_doctests tool ?
- e.g., run by default in a temporary cwd -
- but that could affect doctest execution, and make some things difficult (e.g. importing local code) ??
using tempfile
instead of e.g. data.to_nc4('tmp.nc'),
import pathlib
import testfile
tempdir = pathlib.Path(testfile.TemporaryDirectory())
# ...
path = tempdir / "tmp.nc"
to_nc4(data, path)
result = from_nc4(path)
with a test utility
Or.. A utility to create a temp directory that will be consistently destroyed afterwards might be useful
(as opposed to tempdir which does not arrange for destruction).
# in <testutils.py>
import pathlib
class TempDir(pathlib.Path):
def __init__(self):
# self.context is deleted when self is deleted --> destroys directory
self.context = tempfile.TemporaryDirectory()
self.path_str = self.context.__enter__()
self.path = pathlib.Path(self.dirpath_str)
# a single common per-import object
tempdir = TempDir()
# ...
# in docstrings / docs
# Usage is generally shorter, and directory is removed on program exit
>>> from testutils import tempdir
...
>>> filepath = tempdir.path / "tmp.nc"
>>> to_nc4(data, filepath)
>>> result = from_nc4(filepath)
- Lingua principale
- Python
- Stelle
- 16
- Fork
- 6
- Merge medio
- 2g 20h
- PR unite (30g)
- 2
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di SciTools/ncdata
-
Link Checker ReportApertaautomated issue report
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Fix homepage linkApertascitools
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
-
Fix license controlApertascitools
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Release fix for Iris 3.17Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
Tutte le issue di SciTools/ncdata
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
UKGovernmentBEIS/inspect_ai#6733 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ProyectoRespira/respira-webapp#334 ·
I maintainer di solito rispondono entro 1 giorno
-
bug security-alert
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
spectrayan/carefold#391 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Jakeschincariol/instagram-agent-skill#83 ·
I maintainer di solito rispondono entro 10 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 64/100